1. 程式人生 > 資訊 >微軟 Win11 筆記本 Surface Pro 8/Go 3 國行版將在 10 月 12 日開啟預售

微軟 Win11 筆記本 Surface Pro 8/Go 3 國行版將在 10 月 12 日開啟預售


# mysql-5.7.18-linux-glibc2.5安裝
1.檢查所使用的linux下是否有安裝過mysql
rpm -qa|grep -i mysql
2.刪除安裝過的mysql
rpm -e mysql-5.7.13-linux-glibc2.5-x86_64 --nodeps //載時使用了--nodeps選項,忽略了依賴關係
3.建立mysql的使用者組/使用者, data目錄及其使用者目錄
userdel mysql

groupdel mysql

--

mkdir -p /data/mysql/app

mkdir -p /data/mysql/data

groupadd mysql

useradd -g mysql -M mysql

chown -R mysql:mysql /data/mysql/app

4.解壓安裝包並將解壓包裡的內容拷貝到mysql的安裝目錄/data/mysql/app
tar -xzvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

mv mysql-5.7.18-linux-glibc2.5-x86_64/* /data/mysql/app

rm -rf mysql-5.7.18-linux-glibc2.5-x86_64
5.初始化mysql資料庫
/data/mysql/app/bin/mysqld --user=mysql --basedir=/data/mysql/app --datadir=/data/mysql/data --initialize

####初始化出現錯誤的時候
--/data/mysql/app/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
使用命令---yum install -y libaio
jOifU#&sw6dd
---
tN4>UMM?eD#2
---
frWBuknjw8&t

6.複製mysql服務啟動指令碼及加入PATH路徑

sed -i '52a\export PATH=/data/mysql/app/bin:/data/mysql/app/lib:\$PATH' /etc/profile

source /etc/profile

7. 複製mysql服務啟動配置檔案

1. cp /data/mysql/app/support-files/mysql.server /etc/init.d/mysqld

2. chmod a+x /etc/init.d/mysqld

3. vi /etc/my.cnf
新增:
------------------------------------------------------------------------------------------------#
[mysqld]
datadir=/data/mysql/data
basedir =/data/mysql/app
socket=/data/mysql/app/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0


join_buffer_size = 8M
sort_buffer_size = 8M
read_rnd_buffer_size = 8M
innodb_buffer_pool_size = 16G
max_connections=2000
max_allowed_packet = 20971520
lower_case_table_names=1
tmp_table_size=1073741824
max_heap_table_size=1073741824
query_cache_size=4M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
general_log=on(預設關閉,off)
gtid_mode=ON
enforce_gtid_consistency = ON


# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mysql.log
pid-file=/var/run/mysql.pid


[client]
socket=/data/mysql/app/mysql.sock
#
# include all files from the config directory
#


------------------------------------------------------------------------------------------------#


8.啟動mysql服務並加入開機自啟動
service mysqld start

chkconfig --level 35 mysqld on
9.檢查mysql服務是否啟動
netstat -tulnp |grep 3306

10.修改root預設密碼
mysql -u root -p

alter user 'root'@'localhost' identified by '123ewQ!@#';

flush privileges;

11. 建立資料庫及使用者並授權 (db_name為資料庫名稱)
CREATE DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;(新建test_ejob)

grant all privileges on ming_dao.* to mingdao@'%' identified by '789oiU&*';(%:任何地方都能登入,不限制IP;localhost:只能本伺服器登入;10.10.40.142:)
(all privileges:所有許可權;select:查詢許可權)grant all privileges on *.* to root@'%' WITH GRANT OPTION
(grant select,update on test_ejob.* to test_tmzl@'%' identified by '789oiU&*';)


use mysql
select host,user from mysql.user;(查詢系統所有使用者)
Delete FROM user Where User='carlife' and Host='%';(刪除某個mysql使用者:先進入use mysql,然後再刪除,根據User和Host為唯一主鍵)

grant all privileges on carlife.* to clms@'%' identified by '789oiU&*';


==========================故障處理==========================
(輸入exit退出先)
1. 忘記預設密碼處理方式:
vi /etc/my.cnf

新增:skip-grant-tables

重啟mysql: service mysqld restart

進入mysql:mysql -u root -p 回車,跳過密碼,不用輸入

mysql>update mysql.user set authentication_string=password('123$%ZAQ!') where user='root' and Host = 'localhost';

exit

vi /etc/my.cnf

刪除 skip-grant-tables

重啟mysql

service mysqld restart




2.mysql 8 報錯 caching-sha2-password 時的處理方法
#建立使用者

CREATE USER 'nfl_risk'@'%' IDENTIFIED BY 'nfl_risk';

#授權使用者許可權

grant all privileges on nfl_risk_t2.* to 'nfl_risk'@'%';

#客戶端連線報錯時的處理方法(在安裝mysql8的時候如果選擇了密碼加密,之後用客戶端連線比如navicate,會提示客戶端連線caching-sha2-password,是由於客戶端不支援這種外掛,可以通過如下方式進行修改:)

ALTER USER 'nfl_risk'@'%' IDENTIFIED BY 'nfl_risk' PASSWORD EXPIRE NEVER;

ALTER USER 'nfl_risk'@'%' IDENTIFIED WITH mysql_native_password BY '{nfl_risk}';