windows10版本安裝mysql
1.獲取mysql壓縮包sql
https://dev.mysql.com/downloads/mysql/
2.解壓並配置文件my.ini數據庫
1.解壓的文件路徑 D:\Program Files (x86)\mysql-8.0.11-winx64 2.my.ini 的文件路徑 D:\Program Files (x86)\mysql-8.0.11-winx64\my.ini
配置my.ini文件windows
[mysql] #設置mysql客戶端默認字符集 default-character-set=utf8 [mysqld] #設置3306端口 port = 3306 #設置mysql的安裝目錄 basedir=D:\Program Files (x86)\mysql-8.0.12-winx64 #設置mysql數據庫的數據的存放目錄 datadir=D:\Program Files (x86)\mysql-8.0.12-winx64\data #容許最大鏈接數 max_connections=200 #服務端使用的字符集默認爲8比特編碼的latin1字符集 character-set-server=utf8 #建立新表時將使用的默認存儲引擎 explicit_defaults_for_timestamp=true default-storage-engine=INNODB
3.在管理員身份運行cmd服務器
3.1 安裝mysqldide
mysqld install
3.2 執行命令,初始化data目錄,安裝包中並無data文件夾,運行命令後,會自動在D:\MySQL\mysql-8.0.11-winx64目錄下生成data文件夾:編碼
mysqld --initialize -user=mysql --console
箭頭所指爲初始密碼
3.3啓動mysql加密
net start mysql
4.修改密碼spa
4.1 登陸mysql.net
mysql -u root -p初始化的密碼(須要填上一步初始化的密碼,和p鏈接無空格)
4.2 修改密碼
alter user 'root'@'localhost' identified by 'your password';
4.3 刷新權限
flush privieges;
5.在須要從新安裝mysql的狀況下,能夠刪除mysqld服務
mysqld --remove mysql
5.忘記密碼
後補
Centos版本安裝mysql
[root@virde ~]# wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm [root@virde ~]# sudo yum localinstall mysql80-community-release-el7-1.noarch.rpm
[root@virde ~]# yum repolist enabled | grep "mysql.*-community.*" mysql-connectors-community/x86_64 MySQL Connectors Community 51 mysql-tools-community/x86_64 MySQL Tools Community 63 mysql80-community/x86_64 MySQL 8.0 Community Server 17
[root@virde ~]# sudo yum install mysql-community-server
[root@virde ~]# sudo service mysqld start
Starting mysqld:[ OK ]
[root@virde ~]# sudo grep 'temporary password' /var/log/mysqld.log 2018-04-27T05:20:28.645777Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: nDjEy-#jv7Dn
[root@virde ~]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 19 Server version: 8.0.11 MySQL Community Server - GPL
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Aa123456.'; Query OK, 0 rows affected (0.08 sec)
mysql -u root -p use mysql; update user set host='%' where user='root';
4.2 使用受權的方式
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION; mysql>FLUSH PRIVILEGES
4.3 新特性致使的錯誤並改正
4.3.1 mysql8.0 引入了新特性 caching_sha2_password;這種密碼加密方式客戶端不支持;客戶端支持的是mysql_native_password 這種加密方式;
4.3.2 修改爲mysql_native_password加密模式:
update user set plugin='mysql_native_password' where user='root';
5.忘記密碼
https://blog.csdn.net/xinpengfei521/article/details/80400142