首页 > 代码库 > centos/redhat安装mysql
centos/redhat安装mysql
1、从http://dev.mysql.com/downloads/repo/ 下载对应的rpm文件,我的是版本7,所以下载:mysql-community-release-el7-5.noarch.rpm
#wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm (注:#后面的才是要输入的命令)
#sudo yum localinstall -y mysql-community-release-el7-5.noarch.rpm
2、#yum install mysql-server
# service mysqld start
显示:Redirecting to /bin/systemctl start mysqld.service
ok,mysql安装成功了。
#mysql
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
现在root密码设置成功。
如果你遇到这样的错误:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)
那么恭喜,需执行: #service mysqld stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
#mysql -u root mysql
然后再执行上面的设置密码操作。
centos/redhat安装mysql