Hyper-V安装Ubuntu 18使用笔记 -- MySQL

mysql

mysql 安装

# Debian 10安装[参考](https://linuxize.com/post/how-to-install-mysql-on-debian-10/):
apt-get update && \
	wget http://repo.mysql.com/mysql-apt-config_0.8.13-1_all.deb && \
	apt -y install ./mysql-apt-config_0.8.13-1_all.deb && \
	apt-get update && \
	apt-get -y install mysql-server 

#在163源同步的MySQL包列表 http://mirrors.163.com/mysql/Downloads/MySQL-8.0/ 中找到Ubuntu18.04的包(可以通过搜索mysql-server关键字)获取下地址
wget http://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-server_8.0.19-1ubuntu18.04_amd64.deb-bundle.tar
mkdir mysql
tar xf mysql-server_8.0.19-1ubuntu18.04_amd64.deb-bundle.tar -C mysql/
cd mysql
apt -y install ./*.deb #安装所有的deb
apt-get -f -y install #修复依赖

mysql 默认密码

ubuntu@ubuntu:~$ sudo find / -name mysql# 查找其log位置
/var/log/mysql
ubuntu@ubuntu:~$ cat error.log |grep 'pass'
2020-05-12T04:46:04.915740Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
# 这里说使用空密码

# root用户使用进行了身份验证auth_socket。
# 将plugin更改为时mysql_native_password,我们才可以使用mysql默认密码
cat /etc/mysql/debian.cnf
user     = debian-sys-maint # 配置文件登录用户与密码
password = password_for_the_user

mysql -u debian-sys-maint -p#使用debian-sys-maint用户登录
mysql> USE mysql
mysql> SELECT User, Host, plugin FROM mysql.user;

+------------------+-----------+-----------------------+
| User             | Host      | plugin                |
+------------------+-----------+-----------------------+
| root             | localhost | auth_socket           |
| mysql.session    | localhost | mysql_native_password |
| mysql.sys        | localhost | mysql_native_password |
| debian-sys-maint | localhost | mysql_native_password |
+------------------+-----------+-----------------------+
4 rows in set (0.00 sec)

mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> COMMIT; ## 将plugin更改为时mysql_native_password

mysql 5.7 修改账号密码

#mysql5.7中user表的password字段已被取消,被取代 authentication_string 字段,
# 更改用户密码也不能修改user表来实现了。
mysql> update mysql.user set authentication_string=password('123qwe') \
	where user='root' and Host = 'localhost';
mysql> alter user 'root'@'localhost' identified by '123';
mysql> set password for 'root'@'localhost'=password('123');
mysql> flush privileges;
1、显示数据库列表。 
show databases; 
2、显示库中的数据表: 
use mysql;
show tables; 
3、显示数据表的结构: 
describe 表名; 
4、建库: 
create database 库名; 
5、建表: 
use 库名; 
create table 表名 (字段设定列表); 
6、删库和删表: 
drop database 库名; 
drop table 表名; 
7、将表中记录清空: 
delete from 表名; 
8、显示表中的记录: 
select * from 表名

QAF

Q: ,运行出現ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)】
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &# 接著跳過授權表訪問

Q: ERROR 1698 (28000): Access denied for user ‘root’@‘localhost’
‘skip-grant-tables’>>/etc/mysql/mysql.conf.d/mysqld.cnf

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值