Created
September 19, 2019 09:18
-
-
Save lize240810/4e6e7688b33965ae22b37c52c3b3176c to your computer and use it in GitHub Desktop.
Ubuntu上安装使用mysql 教程 修改初始密码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 安装mysql | |
| ``` | |
| sudo apt install mysql-server | |
| ``` | |
| # ubuntu18.04 首次登录mysql未设置密码或忘记密码解决方法 | |
| 1.首先输入以下指令: | |
| ```shell | |
| sudo cat /etc/mysql/debian.cnf | |
| ``` | |
| 2.输入显示的帐号与密码 | |
| ```sql | |
| mysql -u debian-sys-maint -p | |
| ``` | |
| 3. 修改帐号与密码 | |
| 1.使用mysql | |
| ```sql | |
| use mysql; | |
| ``` | |
| 2.修改帐号与密码 | |
| ```sql | |
| update mysql.user set authentication_string=password('root') where user='root' and Host ='localhost'; | |
| ``` | |
| 3.修改配置 | |
| ``` | |
| update user set plugin="mysql_native_password"; | |
| ``` | |
| 4.保存设置 | |
| ``` | |
| flush privileges; | |
| ``` | |
| 5. 退出 | |
| ``` | |
| quit; | |
| ``` | |
| 4.使用mycli | |
| ``` | |
| sudo apt install mycli | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
赞!原来Ubuntu安装完还有非root默认账号的