mysql基本操作
2019-10-02 本文已影响0人
nnnnzyx
-
安装(版本5.7)
sudo apt-get install mysql-server sudo apt-get install mysql-client sudo apt-get install libmysqlclient-dev sudo netstat -tap | grep mysql
sudo vim /etc/mysql/debian.cnf # 查看默认登陆密码 mysql -u debian-sys-maint -p # 登录 update mysql.user set authentication_string=password('password') where user='root'and Host = 'localhost'; # 更改密码 # 新建mysql账户 CREATE USER 'root_sql'@'localhost' IDENTIFIED BY 'yourpasswd'; GRANT ALL PRIVILEGES ON *.* TO 'root_sql'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES;
# 删除mysql sudo apt-get autoremove --purge mysql-server-5.7 sudo apt-get remove mysql-server sudo apt-get autoremove mysql-server sudo apt-get remove mysql-common # 清理残余数据 dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
# 重启数据库 service mysql restart
# 设置远程连接 sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf # 注释掉bind-address = 127.0.0.1 # 进入mysql服务,执行授权命令 grant all on *.* to root@'%' identified by '你的密码' with grant option; flush privileges;