场景还原:
初始化
#/usr/local/webserver/mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/webserver/mysql/ --datadir=/home/mysqldata
Installing MySQL system tables...
150205 11:48:00 [Note] Flashcache bypass: disabled
150205 11:48:00 [Note] Flashcache setup error is : ioctl failed
OK
Filling help tables...
150205 11:48:00 [Note] Flashcache bypass: disabled
150205 11:48:00 [Note] Flashcache setup error is : ioctl failed
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/local/webserver/mysql//bin/mysqladmin -u root password 'new-password'
/usr/local/webserver/mysql//bin/mysqladmin -u root -h kooxoo17.ktep3.kuxun.cn password 'new-password'
Alternatively you can run:
/usr/local/webserver/mysql//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/local/webserver/mysql/ ; /usr/local/webserver/mysql//bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/webserver/mysql//mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/local/webserver/mysql//scripts/mysqlbug script!
Percona recommends that all production deployments be protected with a support
contract (http://www.percona.com/mysql-suppport/) to ensure the highest uptime,
be eligible for hot fixes, and boost your team's productivity.
启动
/usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --basedir=/usr/local/webserver/mysql/ --datadir=/home/mysqldata &
正常启动。ps -ef | grep mysql 也有相应的进程存在
尝试如下4种方式登录:
# /usr/local/webserver/mysql/bin/mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
# /usr/local/webserver/mysql/bin/mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
# /usr/local/webserver/mysql/bin/mysql -S /tmp/mysql.sock
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
]# /usr/local/webserver/mysql/bin/mysql -u root -S /tmp/mysql.sock
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
而my.cnf中指定的socket就是/tmp/mysql.sock 这个路径
或者如下这种报错:
# /usr/local/webserver/mysql/bin/mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
# /usr/local/webserver/mysql/bin/mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
# /usr/local/webserver/mysql/bin/mysql -S /tmp/mysql.sock
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
#/usr/local/webserver/mysql/bin/mysql -u root -S /tmp/mysql.sock
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
原因是:进行了多次初始化,但是每次初始化的时候没有删除datadir下生成的文件导致的!
切记,每次初始化操作都要删除datadir下生产的文件哦!