授权远程访问mysql超级用户远程访问:
mysql -u root -p
#输入密码,进入mysql客户
use mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root password...' WITH GRANT OPTION;
FLUSH PRIVILEGES; #更新权限
忘记重设mysql 的root密码:
vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables #添加这行
#保存退出
systemctl restart mysqld
mysql -u root
use mysql;
#MySQL 5.7.6 以及最新版本:
update user set authentication_string=PASSWORD('new password') where User='root';
#MySQL 5.7.5 或更早之前的版本:
update user set password=PASSWORD('new password') where User='root';
Mysql5.7的运行SQL语句文件的时候会报下面错误:
of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c
解决方法:
在 /etc/my.cnf 文件里加上如下:
sql_mode='NO_ENGINE_SUBSTITUTION'
重启Mysql服务
mariadb安装:
mariadb安装:
yum install mariadb-server mariadb
mariadb数据库的相关命令是:
systemctl start mariadb #启动MariaDB
systemctl stop mariadb #停止MariaDB
systemctl restart mariadb #重启MariaDB
systemctl enable mariadb #设置开机启动
初始化:
mysql_secure_installation
mariadb配置允许远程访问方式:
mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '20161130' WITH GRANT OPTION;
flush privileges;