Mysql 快速上手合集
Mysql 8.0.12:
1、解壓zip
2、配置環境變量path,
3、配置my.ini
[mysqld]
# 設定3306端口
port=
# 設定mysql的安裝目錄
basedir=D:\\Soft\\mysql8 # 切記此處一定要用雙斜杠\\,單斜杠我這裡會出錯,不過看别人的教程,有的是單斜杠。自己嘗試吧
# 設定mysql資料庫的資料的存放目錄
datadir=D:\\Soft\\mysql8\\Data # 此處同上
# 允許最大連接配接數
max_connections=
# 允許連接配接失敗的次數。這是為了防止有人從該主機試圖攻擊資料庫系統
max_connect_errors=
# 服務端使用的字元集預設為UTF8
character-set-server=utf8
# 建立新表時将使用的預設存儲引擎
default-storage-engine=INNODB
# 預設使用“mysql_native_password”插件認證
default_authentication_plugin=mysql_native_password
[mysql]
# 設定mysql用戶端預設字元集
default-character-set=utf8
[client]
# 設定mysql用戶端連接配接服務端時預設使用的端口
port=
default-character-set=utf8
4、進入mysql安裝路徑,然後輸入
mysqld --console
,随機生成root密碼
qo=seuu;q7lV,啟動成功則會顯示以下提示:
[System] [MY-010116] [Server] D:\Soft\mysql8.0\bin\mysqld.exe (mysqld 8.0.12) starting as process 11596
[Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
[System] [MY-010931] [Server] D:\Soft\mysql8.0\bin\mysqld.exe: ready for connections. Version: '8.0.12' socket: '' port: 3306 MySQL Community Server - GPL.
5、輸入:
mysql -uroot -pqo=seuu;q7lV
登入成功
6、輸入
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
不改變臨時密碼運作sql語句會提示
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
7、建立使用者
CREATE USER 'xxh'@'%' IDENTIFIED WITH mysql_native_password BY 'xxh123!@#';
8、查找使用者
select Host,User,plugin,authentication_string from mysql.user;
9、#授權所有權限
GRANT ALL PRIVILEGES ON *.* TO 'xxh'@'%';
授權基本的查詢修改權限,按需求設定
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON *.* TO 'xxh'@'%';
檢視使用者權限
show grants for 'xxh'@'%';
關閉資料庫
mysqladmin -uroot -proot shutdown