一、mysql 安装
查看是否安装了 mysql
rpm -qa | grep mysql-server
yum install mysql-server
修改配置文件
vim /etc/my.cnf
设置系统服务启动
chkconfig mysqld on
查看设置状态
chkconfig --list mysqld
启动 mysql
service mysql restart
(start stop)
若无法启动,如下命令启动
/etc/rc.d/init.d/mysqld start
二、问题
查看mysqld的log文件
less /var/log/mysqld.log
(1) mysql.sock 不存在 链接 --- > https://www.linuxidc.com/Linux/2009-09/21897.htm
解决方案:
/etc/init.d/mysqld stop
1 $/usr/local/bin/mysql_install_db //重建授权表
3 $/usr/local/bin/mysqld_safe &
/etc/init.d/mysqld start
登入 mysql
# mysql
(2) Access denied for user 'root'@'localhost
# /etc/rc.d/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
mysql>