centos7参考:http://www.cnblogs.com/starof/p/4680083.html
mysql-community-release包下载连接:http://files.cnblogs.com/files/amusic/mysql-community-release-el7-5.noarch.zip
以下为centos6环境,
#以下这条命令是解决云模板中的MariaDB与MySQL相关软件包冲突问题
yum remove MariaDB* -y
#安装启动MySQL数据库服务器
yum install mysql-server -y
#
service mysqld start
#设置数据库管理员初始密码为password
mysqladmin -u root password 'password'
#开启防火墙数据库相关端口
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
service iptables save
#如果使用的是MariaDB,以下命令改为chkconfig mysql on
chkconfig mysqld on
使用mysql工具连接失败:
一:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor
更新权限
#登录mysql
mysql -uroot -ppassword
#切换数据库
>use mysql;
>update user set password=password('newpassword') where user='root';
#更新权限
>flush privileges;
>quit
二:
1130 - host is not allowed to connect to this mysql server
未开启远程连接
解决方案:
#使用root登录mysql
mysql -uroot -ppassword
>use mysql;
#更改user表
>update user set host = '%' where user = 'root';
#验证结果
>select host, user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | root |
| 127.0.0.1 | root |
| centos | |
| centos | root |
| localhost | |
+-----------+------+
5 rows in set (0.00 sec)