You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
2.2 KiB

12 months ago
### 安装$Mysql$ $5.7$
12 months ago
12 months ago
```shell
12 months ago
yum install lrzsz -y
mkdir /usr/local -p
cd /usr/local
rz -be 选择 mysql-5.7.42-el7-x86_64.tar.gz
tar -zxf mysql-5.7.42-el7-x86_64.tar.gz
mv mysql-5.7.42-el7-x86_64 mysql
rm -rf mysql-5.7.42-el7-x86_64.tar.gz
vi /etc/profile
#添加如下内容
export PATH=/usr/local/mysql/bin:$PATH
#然后source生效
source /etc/profile
#添加用户并授权相关
useradd mysql
id mysql
mkdir /data/mysql -p
chown -R mysql:mysql /usr/local/mysql/*
chown -R mysql:mysql /data/*
其中:
/usr/local/mysql/是MySQL软件所在目录。
/data/mysql是将来存放MySQL数据的目录。
#初始化数据库
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
#配置文件
vi /etc/my.cnf
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
server_id=1
port=22066
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock
12 months ago
```
#### 忽略大小写
```shell
lower_case_table_names=1
```
12 months ago
12 months ago
#### 管理MySQL_etc/init.d
```shell
12 months ago
mkdir /etc/init.d -p
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
12 months ago
```
12 months ago
12 months ago
#### 重定向文件
```
12 months ago
ln -s /usr/lib64/libncurses.so.6.2 /usr/lib64/libncurses.so.5
ln -s /usr/lib64/libtinfo.so.6.2 /usr/lib64/libtinfo.so.5
12 months ago
#启动、重启命令
service mysqld start
service mysqld restart
12 months ago
```
12 months ago
12 months ago
#### 重置密码
```
12 months ago
/etc/init.d/mysqld stop
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql
update mysql.user set authentication_string=PASSWORD("DsideaL147258369") where user='root' and host='localhost';
12 months ago
flush privileges;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'DsideaL147258369' WITH GRANT OPTION;
12 months ago
flush privileges;
exit
12 months ago
12 months ago
/etc/init.d/mysqld restart
12 months ago
mysql -uroot -pDsideaL147258369
12 months ago
```
12 months ago
12 months ago
现在用Navicat Prenium就可以远程访问到数据库了。
12 months ago
```
12 months ago
YLT项目中使用的用户名ycharge密码ycharge 需要创建
CREATE USER 'ycharge'@'%' IDENTIFIED BY 'ycharge';
GRANT all privileges ON yltcharge.* TO 'ycharge'@'%';
FLUSH PRIVILEGES;
12 months ago
```
12 months ago
12 months ago
12 months ago
#### 创建使用账号
```sql
GRANT ALL PRIVILEGES ON *.* TO ycharge@"%" IDENTIFIED BY "ycharge";
flush privileges;
```