您的位置:首页 > 数据库 > MySQL

mysql问题总结,远程登录

2014-03-06 13:49 169 查看
http://blog.sina.com.cn/s/blog_4550f3ca0101axzd.html 更改mysql数据库的数据库名

http://tech.sina.com.cn/s/s/2008-12-24/09322685701.shtml

http://www.cnblogs.com/sunson/articles/2172086.html

http://blog.csdn.net/jscpb/article/details/7199319

ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value
mysql> QUIT;

解决办法:打开my.cnf,查找

sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

修改为

sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

然后重启MYSQL

因为要搞一个项目,所以需要安装MySql,以往安装MySql都是非常顺利的,尤其MySql提供的rmp包,只需双击下就可以搞定~但不知道什么时
候,MYSQL ERROR 1045 (28000): Access denied for user (using password:
YES),这个拒绝访问问题变得非常广泛。

百度了一下,没有现成的解决方法,唯有找出其问题所在了。

解决问题思路:

第一步,先使用跳过受权表访问,命令如下:mysqld_safe --user=mysql --skip-grant-tables --skip-networking & (当然,在这之前,先停止mysql服务的运行)。

[root@Linux usr]# ps -A|grep mysql
28255 ? 00:00:00 mysqld_safe
28375 ? 00:00:00 mysqld
[root@Linux usr]# kill -9 28255
[root@Linux usr]# kill -9 28375
[root@Linux usr]# ps -A|grep mysql
[root@Linux usr]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 28852
[root@Linux usr]# 140306 11:26:35 mysqld_safe Logging to '/var/lib/mysql/Linux.err'.
140306 11:26:35 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

在启动一个xshell客户端,运行mysql命令

第二步,mysql -uroot mysql 登录mysql。

mysql> insert into mysql.user(Host,User,Password)values("127.0.0.1","mysql",password("mysql"));

Query OK, 1 row affected, 3 warnings (0.00 sec)

创建用户:

  mysql> insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));

  这样就创建了一个名为:test 密码为:1234 的用户。

  注意:此处的"localhost",是指该用户只能在本地登录,不能在另外一台机器上远程登录。如果想远程登录的话,将"localhost"改为"%",表示在任何一台电脑上都可以登录。也可以指定某台机器可以远程登录。

1、进入mysql,创建一个新用户xuys:

   格式:grant 权限 on 数据库名.表名 用户@登录主机 identified by "用户密码";

   grant select,update,insert,delete on *.* to xuys@192.168.88.234 identified by "xuys1234";

   查看结果,执行:

   use mysql;

   select host,user,password from user;

   可以看到在user表中已有刚才创建的xuys用户。host字段表示登录的主机,其值可以用IP,也可用主机名,

mysql> grant select,update,insert,delete on mysql.* to mysql@127.0.0.1 identified by "mysql";
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> grant select,update,insert,delete on mysql.* to mysql@127.0.0.1 identified by "mysql";
Query OK, 0 rows affected (0.00 sec)



修改/usr/my.cnf端口号改成3306即可解决。



mysql> GRANT ALL PRIVILEGES ON mysql.* TO 'mysql'@'%' IDENTIFIED BY 'mysql' WITH GRANT OPTION; ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON mysql.* TO 'mysql'@'%' IDENTIFIED BY 'mysql' WITH GRANT OPTION; Query OK, 0 rows affected (0.01 sec)

可登陆访问



错误描述:

错误代码:1130

Host ***.***.***.*** is not allowed to connect to this MySQL server

解决方法:

① 改表法:

可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改“mysql”数据库里的“user”表里的“host”项,从“localhost”改称”%”

mysql -u root -p

mysql>use mysql;

mysql>update user set host = ‘%' where user =’root’;

mysql>flush privileges;

mysql>select host,user from user where user=’root’;

现在就可以连接了!

② 授权法

例如,你想root使用root从任何主机连接到mysql服务器的话。

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

如果你想允许用户root从ip为192.168.1.3的主机连接到mysql服务器,并使用root作为密码

GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.3' IDENTIFIED BY 'root' WITH GRANT OPTION;

判断innodb是否已安装

mysql> show plugins;



mysql> show grants;

mysql> show grants for 'mysql';

如果连接mysql用户的ip地址变了,用这个语句改变。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: