四、cent OS安装配置mysql
时间:2021-07-01 10:21:17
帮助过:15人阅读
- 下载mysql的repo源
$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
- 安装mysql-community-release-el7-5.noarch.rpm包
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
安装这个包后,会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。
- 安装mysql
sudo yum install mysql-server
- 登录mysql
mysql -u root
登录时有可能报这样的错:ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2),原因是/var/lib/mysql的访问权限问题。下面的命令把/var/lib/mysql的拥有者改为当前用户:
sudo chown -R root:root /var/lib/mysql
- 重启mysql服务
service mysqld restart(如果失败,换:service mysql restart)
- 登录重置密码
$ mysql -u root //直接回车进入mysql控制台
mysql > use mysql;
mysql > update user set password=password(‘123456‘) where user=‘root‘;
mysql > exit;
- 如果你需要远程登录
1)是否开放了3306端口?你把防火墙关闭试试。
2)增加允许远程连接 MySQL 用户并授权。
mysql> grant all PRIVILEGES on db_name.* to ‘username‘@‘xxx.xxx.xx.x‘ identified by ‘password‘ WITH GRANT OPTION;
参考文章:http://www.linuxidc.com/Linux/2016-09/134940.htm
四、cent OS安装配置mysql
标签:远程登录 repos username repo htm lease word 授权 tle