启动mysql命令: service mysqld start
https://blog.csdn.net/u010565545/article/details/104961184
用 SSH客户端登录上以后
首先启动数据库:
[root@iZm5ec880z2rorZ ~]# service mysqld start
可以输入一下加粗命令:
[root@iZm5ec880z2rorZ ~]# mysql -u root -p
Enter password: (输入你的数据库密码)
Welcome to the MySQL monitor. Commands end with or \g.
Your MySQL connection id is 5
Server version: 5.1.73-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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> use mysql
Database changedmysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'ldyu123' WITH GRANT OPTION
Query OK, 0 rows affected (0.00 sec)
mysql> commit
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges
Query OK, 0 rows affected (0.00 sec)
mysql> exit
退出后,输入下边的命令:
[root@iZm5ec880z2rorZ ~]# service mysqld restart
Shutting down MySQL... [ OK ]
Starting MySQL. [ OK ]
阿里云ECS云服务器 --(ubunto)Bitvise SSH --和阿里云通讯,免费的,从putty主页上下载的
Notepadd++ --免费的文件编辑
方法/步骤
下载免费的Bitvise用来和阿里云通讯。
根据阿里云的ip地址和账户信息设置SSH链接。
点击login,同时打开命令窗口和SFTP窗口(类似ftp那样的下载上传)。
找到服务器上的位置/etc/my.cnf,并下载一份备份在本地(后面还用,留一份原版的不要动)。
用Notepadd++打开my.cnf文件,在[mysqld]的段中加上一句:skip-grant-tables 例如: [mysqld] datadir=/var/lib/mysql skip-grant-tables 保存
将修改过的my.cnf上传到阿里云服务器上原来的位置覆盖旧的文件。
通过命令窗口,重新启动mysql # /etc/init.d/mysql restart
成功后,窗口反馈:
Stopping MySQL: [ OK ] Starting MySQL: [ OK ]
接下来,还是在命令窗口,进入mysql;输入
mysql>USE mysql
mysql>UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root'
完成
退出mysql。
命令窗口 mysql>quit 回车
7
将最初备份的原始my.cnf重新上传并覆盖服务器上的文件。/etc/my.cnf (skip-grant-tables删除 )最后重新启动mysqld # /etc/init.d/mysqld restart
输入mysql -u root -p就会提示输入新密码,输入刚才设置的秘密就可以进去,说明设置成功。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)