-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_READLINE=1 \-DENABLED_LOCAL_INFILE=1 \-DMYSQL_DATADIR=/data/ mysql/ \-DMYSQL_TCP_PORT=3306
-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data/ \
-DMYSQL_TCP_PORT=3306
所以上面的編譯條件省掉了如下兩行-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_MEMORY_STORAGE_ENGINE=1 \但INNODB一定要聲明式安裝,所以多了這一行-DWITH_INNOBASE_STORAGE_ENGINE=1 \
[root@localhost ~]# useradd mysql -g mysql -s /sbin/nologin #
添加mysql用戶
[root@localhost ~]# chown mysql.mysql -R . #將mysql目錄賦予mysql用戶的執行權限
[root@localhost ~]# chown mysql.mysql -R /data/mysql
[root@localhost ~]# chmod 755 scripts/mysql_install_db #賦予mysql_install_db執行權限
[root@localhost ~]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/
[root@localhost ~]# chmod 755 /etc/init.d/mysqld
初始化 MySQL 數據庫: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h centos.huoba password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[root@localhost ~]# /usr/local/mysql/bin/mysql -u root -p #敲入該命令後,屏幕會提示輸入密碼,輸入上一步設置的yourpassword
刪除root密碼爲空的記錄
mysql> use mysql;
mysql> delete from user where password='';
mysql> flush privileges;