Ubuntu18安装MySQL

Ubuntu18安装MySQL
第一步:安装MySQL
sudo apt-get install mysql-server 无法通过apt安装,应该是兼容性问题
sudo apt install mysql-client 安装client端
sudo apt install libmysqlclient-dev 安装依赖
netstat -tap | grep mysql 查看是否运行(参数:-t=tcp,-a=all,-p=显示程序名称)
第二步:进入MySQL
1、登录,命令:mysql -u root -p
第一次安装是不需要密码登录的,前提是在root用户下登录,不然会报登录错误:ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)
别慌,使用以下命令:
切换到根用户:su xxx(根用户名)
再次输入:mysql -u root -p
再按enter键,跳过输入密码步骤
2、修改登录密码
//展示数据库
show databases;
//选择MySQL数据库
use mysql;

//修改root用户的密码和插件类型
update user set plugin=“mysql_native_password”,authentication_string=password(“123456”) where user=“root”;

//刷新权限
flush privileges;
//退出MySQL
qiut
再次重新登录

具体安装过程也可以参考这位大神的文章:https://blog.csdn.net/u010986776/article/details/79860418

删库重装操作:
重要的一点,先停止数据库,在重装。不然会报一些错误,让你搜断手。
首先 sudo service mysql stop

sudo rm /var/lib/mysql/ -R

sudo rm /etc/mysql/ -R

sudo apt-get autoremove mysql* --purge

sudo apt-get remove apparmor

sudo apt-get install mysql-server mysql-common

参考链接:https://blog.csdn.net/miao0967020148/article/details/80218170

安装的参考过程:
root@zlb:/home/root_zlb# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.38-0ubuntu0.18.04.1 (Ubuntu)

Copyright © 2000, 2022, Oracle and/or its affiliates.

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> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
±-------------------+
4 rows in set (0.00 sec)

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> show tables;
±--------------------------+
| Tables_in_mysql |
±--------------------------+
| columns_priv |
| db |

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值