
正确的修改密码步骤:
①update mysql.user set password=PASSWORD('新密码') where user='root'
②flush privileges(必须)
问题描述:
修改mysql密码后,无法再次连接。
问题原因:
上面那行命令中password=PASSWORDD('新密码'),写成了password='新密码',修改过程都没报错,quit bye后,就被拒绝连接了,hhhhhh2333完美PerfectParfait=_=......所以大家一定要小心别写错....
解决办法:
接下来就可以见证奇迹的时刻了!
Mission complete!
安装mysql,在终端输入如下命令并回车:brew install mysql
等待大概5分钟(视网速而定)执行完毕后,会看到这一段提示:
/usr/local/Cellar/mysql/5.7.9/bin/mysqld --initialize-insecure --user=comet
==>Caveats
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
可以看到brew在安装的时候已经初始过mysql了(不用再像网上说的再执行mysql_install_db命令),且当前没有密码
于是我按照它的提示,执行命令:
mysql_secure_installation
需要密码时,直接回车,出现了如下的错误:
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
我在tmp目录下并没有看到mysql.sock这个文件。
我猜想它是在mysql服务启动时才会创建,于是我提前执行了如下的命令:
mysql.server start
提示 .SUCCESS!
这时tmp目录下有mysql.sock这个文件了,于是我继续执行 mysql_secure_installation
cometdeMacBook-Pro:~ comet$ mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: N // 这个选yes的话密码长度就必须要设置为8位以上,但我只想要6位的
Please set the password for root here.
New password:// 设置密码
Re-enter new password: // 再一次确认密码
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y// 移除不用密码的那个账户
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
OK!搞定,可以使用mysql -u root -p 进行密码连接了
通过Windows的服务管理器查看。首先安装Maki5。服务端 “开始”-“运行”,输入“services.msc”,回车。d出Windows的服务管理器,然后就可以看见服务名为“mysql”的服务项了,其右边标明“已启动”。注意:装好MYSQL后最好重新启动系统。
1.将服务端Zebra目录复制到MYSQL的DATA目录下
2.找到MYSQL目录里的MY.INI文件,修改my.ini配置文件的[mysqld]下增加lower_case_table_names=2,确定表名和库名是大小写敏感的,改完后重新启动mysql。这段添加完成后,需要将MYSQL服务关闭重启方可生效(不要在任务管理器里关闭程序),可以重起一下机器。
3.将“Maki5”这个目录复制到C盘以外的盘,最好不要用中文名,比如放在E盘的Maki5目录下
4.打开ConfigTool.exe这个程序就是服务器启动的主程序,
5.设置这里读取MYSQL数据库的ROOT名和密码,这里的用户名一般就是ROOT,密码改成自己刚才安装MYSQL时所输入的密码,注意,这里有好几处需要改的,图的上面所画圈的项目里的密码都要改成自己的,否则连接不上,全部修改完后别忘了保存。
6.看一下启动设置里的程序目录是否正确,所有运行的程序都要指定在自己所在的目录,比如E:\Maki5\目录
7.现在点击启动运行看看效果,就可以查看了。
如何修改MySql数据库的用户名和密码:
首先进入命令行下:
以root用户登录,命令:mysql -uroot -p 回车 输入密码;
mysql>use mysql;
mysql>UPDATE user SET password=PASSWORD('输入新密码') WHERE user='root'
mysql>FLUSH PRIVILEGES
已经完成。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)