[root@bogon mysql-5.5.60]# service mysqld start
starting mysql.logging to '/usr/local/mysql-5.5.60/data/bogon.err'.
201106 12:50:02 mysqld_safe directory '/var/lib/mysql' for unix socket file don't exists.
error! the server quit without updating pid file (/usr/local/mysql-5.5.60/data/bogon.pid).
解决方法
随即执行命令:cat /usr/local/mysql/data/iz2ze8hspx8qsmxx7b1i9sz.err查看错误原因
error内容如下:
[error] can't start server : bind on unix socket: permission denied
[error] do you already have another mysqld server running on socket: /var/lib/mysql/mysql.sock ?
结合先前写入配置/etc/my.cnf:
[root@bogon lib]# mkdir mysql
[root@bogon lib]# chmod 777 -r mysql/
最终:
[root@bogon lib]# service mysql start
starting mysql... success!
4 配置环境变量
配置path
# vi ~/.bash_profile
在文件最后面加入以下内容,并使用:wq保存
export path=$path:/usr/local/mysql-5.5.60/bin
刷新path
# source ~/.bash_profile
四、登录并配置远程登录
1 首次登录mysql
[root@bogon lib]# mysql -uroot -p
2 *报错及解决方法
[root@bogon lib]# mysql -uroot -p
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: no such file or directory
系统是redhad8,binary方式安装完mysql之后,mysql命令登录不成功,报错:mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: no such file or directory。按照百度的方法都不成功,应该和系统版本有关,后来自己想到一个方法:yum install libncurses*,完美解决问题。
解决:
[root@bogon lib]# yum -y install libncurses*
[root@bogon lib]# mysql -uroot -p
enter password: #直接回车登录
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection id is 2
server version: 5.5.62 mysql community server (gpl)
copyright (c) 2000, 2018, oracle and/or its affiliates. all rights reserved.
oracle is a registered trademark of oracle corporation and/or its
affiliates. other names may be trademarks of their respective
owners.
type 'help;' or '\h' for help. type '\c' to clear the current input statement.
mysql>
3 修改root密码
mysql> use mysql;
reading table information for completion of table and column names
you can turn off this feature to get a quicker startup with -a
database changed
mysql> update user set password=password('需要设置的密码') where user='root' and host='localhost';
query ok, 1 row affected (0.00 sec)
rows matched: 1 changed: 1 warnings: 0
mysql> update user set password=password('12345') where user='root' and host='localhost';
query ok, 1 row affected (0.00 sec)
rows matched: 1 changed: 1 warnings: 0
mysql> flush privileges;
query ok, 0 rows affected (0.00 sec)
4 设置远程登录
mysql> grant all privileges on *.* to 'root'@'%' identified by '12345' with grant option;
query ok, 0 rows affected (0.00 sec)
mysql> flush privileges;
query ok, 0 rows affected (0.00 sec)