ubuntu14.10下解决MYSQL安装错误:"ERROR 1045 (28000)
2016-06-23 18:35
609 查看
原文链接: http://blog.csdn.net/Cryhelyxx/article/details/42420253
修改mysql数据库用户root的密码请看:http://blog.csdn.net/cryhelyxx/article/details/39475433
好了, 了解了上面两篇文章后, 我们假设你已在ubuntu下成功安装上了mysql数据库。
启动ubuntu14.10系统后, ctrl + alt + t打开终端
首先进入mysql的安装目录下启动mysql服务:
启动mysql服务后, 接着我们进入mysql的shell, 即进入mysql的控制台
发现出现拒绝访问“ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)”信息。
回到上面, 我们在刚刚安装完mysql数据库是未对mysql中的root用户进行密码设置的。下面我们通过修改mysql中的root用户密码进行解决问题。
mysql服务停止后, 执行以下命令, 这里我们sudo -s切换到root管理员下执行命令,如下
当出现上面的信息时, 我们再ctrl + alt + t打开另一个终端窗口, 键入mysql -u root mysql进入mysql的shell下, 并可以修改mysql里root用户的密码
如下:
即上面三个命令就可完成mysql里root用户的密码修改。
启动mysql服务如下:
上面提示密码显示不安全信息, 我们也可以键入
然后再接入mysql用户root的新密码进行登录shell即可, 如下
OK, Enjoy it!!!
问题描述
ubuntu下mysql数据库的安装看:http://blog.csdn.net/cryhelyxx/article/details/23551605修改mysql数据库用户root的密码请看:http://blog.csdn.net/cryhelyxx/article/details/39475433
好了, 了解了上面两篇文章后, 我们假设你已在ubuntu下成功安装上了mysql数据库。
启动ubuntu14.10系统后, ctrl + alt + t打开终端
首先进入mysql的安装目录下启动mysql服务:
xx@ubuntu:~$ cd /usr/local/mysql/ xx@ubuntu:/usr/local/mysql$ sudo ./support-files/mysql.server start Starting MySQL .. * xx@ubuntu:/usr/local/mysql$
启动mysql服务后, 接着我们进入mysql的shell, 即进入mysql的控制台
xx@ubuntu:/usr/local/mysql$ mysql -u root mysql ERROR 1045 (28000): Access denied for user 'xx'@'localhost' (using password: NO) xx@ubuntu:/usr/local/mysql$
发现出现拒绝访问“ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)”信息。
回到上面, 我们在刚刚安装完mysql数据库是未对mysql中的root用户进行密码设置的。下面我们通过修改mysql中的root用户密码进行解决问题。
解决方法
我们先把mysql的服务停止下来xx@ubuntu:/usr/local/mysql$ sudo ./support-files/mysql.server stop Shutting down MySQL .. * xx@ubuntu:/usr/local/mysql$
mysql服务停止后, 执行以下命令, 这里我们sudo -s切换到root管理员下执行命令,如下
./mysqld_safe --user=mysql --skip-grant-tables --skip-networking& root@ubuntu:/usr/local/mysql# cd bin/ root@ubuntu:/usr/local/mysql/bin# ./mysqld_safe --user=mysql --skip-grant-tables --skip-networking& [1] 5810 root@ubuntu:/usr/local/mysql/bin# 150104 19:01:43 mysqld_safe Logging to '/usr/local/mysql/data/ubuntu.err'. 150104 19:01:43 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data 150104 19:15:35 mysqld_safe mysqld from pid file /usr/local/mysql/data/ubuntu.pid ended
当出现上面的信息时, 我们再ctrl + alt + t打开另一个终端窗口, 键入mysql -u root mysql进入mysql的shell下, 并可以修改mysql里root用户的密码
如下:
xx@ubuntu:~$ mysql -u root mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.7.5-m15 MySQL Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> UPDATE user SET Password=PASSWORD('123456') whereUSER='root'; ERROR 1064 (42000): 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 'whereUSER='root'' at line 1 mysql> use mysql; Database changed mysql> UPDATE user SET password=PASSWORD('123456') WHERE user='root'; Query OK, 1 row affected (0.22 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.03 sec) mysql> exit Bye xx@ubuntu:~$ mysql -uroot -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.5-m15 Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> quit Bye xx@ubuntu:~$ mysql>use mysql; mysql>UPDATE user SET password=PASSWORD('newpassword') WHERE user='root'; mysql>FLUSH PRIVILEGES;
即上面三个命令就可完成mysql里root用户的密码修改。
再次以新密码进入mysql的shell
如果mysql未启动, 请先启动mysql服务, 再来执行命令启动mysql服务如下:
xx@ubuntu:~$ cd /usr/local/mysql/ xx@ubuntu:/usr/local/mysql$ sudo ./support-files/mysql.server start Starting MySQL .. * xx@ubuntu:/usr/local/mysql$ $ mysql -uroot -p123456 xx@ubuntu:~$ mysql -uroot -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.5-m15 MySQL Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> quit Bye xx@ubuntu:~$ mysql -uroot -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.5-m15 MySQL Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
上面提示密码显示不安全信息, 我们也可以键入
$ mysql -uroot -p
然后再接入mysql用户root的新密码进行登录shell即可, 如下
xx@ubuntu:~$ mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.5-m15 MySQL Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
OK, Enjoy it!!!
相关文章推荐
- 如何使用MarkDown 使 代码块高亮
- 数据库
- Intro to PyShark for Programmatic Packet Analysis
- 【干货】微信排版实用经验,看后操作立马上手
- visual studio运行时库MT、MTd、MD、MDd的研究(转载)
- 自己学Docker:9.基于Dockerfile创建镜像
- 脉冲时滞微分方程matlab方程
- webpack 处理html中img的src引入的图片
- RHEL 8使用的内核版本
- 基于request.getAttribute与request.getParameter的区别详解
- 简单实现Windows服务 TopShelf
- 推荐几款jquery图片切换插件
- python+opencv开发环境之ValueError错误的解决方法
- C提高 7 单向链表,传统链表
- Unity Shape sdk 安卓问题
- php中curl
- 第12课第5节 字符设备驱动程序之poll机制
- nagios监控插件 nagios_oracle_health+check_linux_stats.pl
- System.Security.SecurityException The source was not found, but some or all event logs could not be searched.Inaccessible logs Security.
- 【原创】linux命令-Axel命令 - linux多线程下载 - 费元星 - 未来星开发团队