MySQL Yum Repository:https://dev.mysql.com/downloads/repo/yum/
[ContOS] MySQL安装部署:https://blog.csdn.net/u011424614/article/details/94555816
[Windows] MySQL安装部署:https://blog.csdn.net/u011424614/article/details/102466819
CentOS基础操作命令:https://blog.csdn.net/u011424614/article/details/94555916
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
mkdir /opt/mysql
cd /opt/mysql
wget https://repo.mysql.com//mysql80-community-release-el7-9.noarch.rpm
yum -y localinstall mysql80-community-release-el7-9.noarch.rpm
rpm -ivh mysql80-community-release-el7-9.noarch.rpm
yum install mysql-server --nogpgcheck
/usr/local/mysql
/var/lib/mysql
/var/log/mysql
/etc/mysql
#-- 启动服务
systemctl start mysqld
#--开机自启动
systemctl enable mysqld
systemctl daemon-reload
#-- 服务状态
systemctl status mysqld
netstat -anp|grep 3306
grep "A temporary password" /var/log/mysqld.log
sKylT1n07s&h
2023-08-14T09:06:10.533287Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: sKylT1n07s&h
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root@123456';
use mysql;
#-- 查询 Host 值
SELECT User, Host FROM mysql.user WHERE User = 'root';
#-- Host 修改为 %
update user set host='%' where user='root' and host='localhost';
#-- 刷新权限
flush privileges;
ALTER USER 'root'@'%' IDENTIFIED BY 'Root#@123456';
mysql --help | grep cnf
vim /etc/my.cnf
[mysqld]
port=3306
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
vim /etc/my.cnf
[mysqld]
log-bin=mysql-bin
server-id=1
systemctl restart mysqld
show variables like '%log_bin%';
show master logs;
SHOW VARIABLES LIKE 'validate_password.%';
+-------------------------------------------------+--------+
| Variable_name | Value |
+-------------------------------------------------+--------+
| validate_password.changed_characters_percentage | 0 |
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 8 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | MEDIUM |
| validate_password.special_char_count | 1 |
+-------------------------------------------------+--------+
8 rows in set (0.01 sec)
#-- validate_password.length 是密码的最小长度,默认是8,改成6
set global validate_password.length=6;
#-- validate_password.policy 验证密码的复杂程度
set global validate_password.policy=0;
#-- validate_password.check_user_name 用户名检查,用户名和密码不能相同,改为关掉
set global validate_password.check_user_name=off;
select host,user,password_expired from user;
+-----------------------+------+------------------+
| host | user | password_expired |
+-----------------------+------+------------------+
| localhost | root | N |
| localhost.localdomain | root | Y |
| 127.0.0.1 | root | Y |
| ::1 | root | Y |
+-----------------------+------+------------------+
4 rows in set (0.00 sec)
use mysql;
#-- 修改过期标识
update user set password_expired='N' where user='root';
#-- 刷新权限
flush privileges;
Linux:
1. 数据库和表名严格区分大小写;
2. 表的别名严格区分大小写;
3. 列名和列的别名忽略大小写;
4. 变量名严格区分大小写
Windows:
1. 不区分大小写
Mac OS:
1. 不区分大小写
show variables like 'lower%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_file_system | OFF |
| lower_case_table_names | 0 |
+------------------------+-------+
2 rows in set (0.01 sec)
vim /etc/my.cnf
[mysqld]
lower_case_table_names=1
systemctl restart mysqld
解决报错:java.sql.SQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: “Too many connections”
show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 151 |
+-----------------+-------+
1 row in set (0.05 sec)
vim /etc/my.cnf
max_connections = 1000
systemctl restart mysqld
CREATE DATABASE nacos_config;
use nacos_config;
source /opt/nacos/conf/mysql-schema.sql;
SHOW TABLES;
select version() from dual;
+-----------+
| version() |
+-----------+
| 8.0.34 |
+-----------+
功能 | 命令 |
---|---|
systemctl start mysqld | 启动服务 |
systemctl enable mysqld | 开机自启动 |
systemctl status mysqld | 服务状态 |
systemctl restart mysqld | 重启服务 |
systemctl stop mysqld | 停止服务 |
mysql -uroot -p | 客户端登录 |