ubuntu,windows 卸载安装mysql

首先删除mysql:

sudo apt-get remove mysql-*
  • 1

然后清理残留的数据

dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
  • 1

它会跳出一个对话框,你选择yes就好了 
然后安装mysql

sudo apt-get install mysql-client mysql-server 

或者:

sudo apt-get install mysql-server-5.6


安装的时候会提示要设置root密码,如果你没有在卸载的时候去清理残留数据是不会提示你去设置root密码的 
检查mysql是不是在运行

sudo service mysql status
  • 1

一般安装完成之后都是会自动运行的。 
如果没有运行你可以

sudo service mysql start

如果不启动会遇到以下问题:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'  https://www.oschina.net/question/588341_2268198

运行它

给mysql设置初始密码:

liyafei@liyafei>mysqladmin -u root password 'new-password'
   格式:mysqladmin -u用户名 -p旧密码 password 新密码
   例1:给root加个密码123456。
   键入以下命令 :
   [root@test1 local]# /usr/bin/mysqladmin -u root password 123456

 

 

 

忘记密码,重置密码等

,忘记了虚拟机上的MYSQL的密码,找到了解决方法~~~~~

1、结束当前正在运行的mysql进程。
# /etc/init.d/mysql stop

2、用mysql安全模式运行并跳过权限验证。
# /usr/bin/mysqld_safe --skip-grant-tables

3、重开一个终端以root身份登录mysql。
# mysql -u root

4、修改root用户口令。
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set Password = PASSWORD('root') where User ='root';

 

修改密码出现错误:ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE t

解决方法:https://www.2cto.com/database/201509/442838.html


Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> exit

5、结束mysql安全模式,用正常模式运行mysql。
# /etc/init.d/mysql restart

6、试试你新修改的口令
 
mysql> show grants for 'root'@'127.0.0.1'; 

mysql> flush privileges;
mysql> quit

None
 
7:windows安装mysql  binary 格式
为root设置密码
GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456';
 
卸载mysql  
 
mysql 8 安装:
posted @ 2018-03-14 15:58  1367356  阅读(152)  评论(0编辑  收藏  举报