Linux上通过mysql命令访问MySQL数据库时常见问题汇总
Posted nicetime
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux上通过mysql命令访问MySQL数据库时常见问题汇总相关的知识,希望对你有一定的参考价值。
Linux上通过mysql命令访问MySQL数据库时常见问题汇总
1)创建登录账号
#创建用户并授权
#允许本地访问
create user ‘test‘@‘localhost‘ identified by ‘123456‘;
#允许外网访问
create user ‘test‘@‘%‘ identified by ‘123456‘;
#grant 权限 on 数据库.* to ‘用户名‘@‘登录主机‘ identified by ‘密码‘;
#原始密码为:123456 加密后的密码为:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
grant all privileges on *.* to ‘root‘@‘%‘ identified by password ‘*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9‘ with grant option;
#用户通过本地IP访问数据库
grant all privileges on *.* to ‘test‘@‘localhost‘ identified by ‘123456‘;
#用户通过外网IP访问数据库
grant all privileges on *.* to ‘test‘@‘%‘ identified by ‘123456‘;
#刷新权限
flush privileges;
#创建数据库
create database 数据库名;
#删除数据库
drop database 数据库名;
#删除表
drop table 表名;
#删除用户及权限
drop user ‘用户名‘@‘localhost‘;
drop user ‘用户名‘@‘%‘;
#刷新权限
flush privileges;
2)正常登录的命令
mysql -utest -p123456 -P3306 -h192.168.48.129
3)mysql命令找不到
[[email protected] src]$ mysqls -utest -p123456 -P3306 -h192.168.48.129
bash: mysqls: command not found
4)参数u大写ERROR 1064 (42000)...use near ‘st‘ at line 1
[[email protected] src]$ mysql -Utest -p123456 -P3306 -h192.168.48.129
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘st‘ at line 1
5)用户名错误 ERROR 1045 (28000)...Access denied
[[email protected] src]$ mysql -utest1 -p123456 -P3306 -h192.168.48.129
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user ‘test1‘@‘192.168.48.129‘ (using password: YES)
6)P为大写或和密码之间有空格或密码错误 ERROR 1045 (28000)...Access denied
[[email protected] src]$ mysql -utest -p 123456 -P3306 -h192.168.48.129
Enter password:
ERROR 1045 (28000): Access denied for user ‘test‘@‘192.168.48.129‘ (using password: NO)
[[email protected] src]$ mysql -utest -P123456 -P3306 -h192.168.48.129
ERROR 1045 (28000): Access denied for user ‘test‘@‘192.168.48.129‘ (using password: NO)
[[email protected] src]$ mysql -utest -p1234567 -P3306 -h192.168.48.129
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user ‘test‘@‘192.168.48.129‘ (using password: YES)
7)端口号不对 ERROR 2003 (HY000):Can‘t connect to MySQL...(111)
[[email protected] src]$ mysql -utest -p123456 -P3307 -h192.168.48.129
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘192.168.48.129‘ (111)
8)连接数据库的地址不对 ERROR 2003 (HY000): Can‘t connect to MySQL...(113)
[[email protected] src]$ mysql -u test -p123456 -P 3306 -h 192.168.48.121
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘192.168.48.121‘ (113)
9)地址中包含端口号信息 ERROR 2005 (HY000): Unknown MySQL...(0)
[[email protected] src]$ mysql -u test -p123456 -P 3306 -h 192.168.48.129:3306
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2005 (HY000): Unknown MySQL server host ‘192.168.48.129:3306‘ (0)
以上是关于Linux上通过mysql命令访问MySQL数据库时常见问题汇总的主要内容,如果未能解决你的问题,请参考以下文章
我把linux上mysql设置为可以通过root用户对所有的数据库进行远程访问,现在想把root用户的远程访问权限?