推薦安裝步驟博客,寫的很詳細,如果不會安裝的話,可以根據安裝步驟一直走。
Windows10下超詳細Mysql安裝_win10安裝mysql-CSDN博客
修改 my.cnf或者my.ini 找到里面bind-address將bind-address = 127.0.0.1設置成bind-address = 0.0.0.0(設備地址)或者直接注釋該行設置完重啟mysql
mysql 8.0找不到my.ini配置文件
直接在bin文件夾同級目錄,新建my.ini文件。
添加內容如下:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_bin
init_connect='SET NAMES utf8mb4'
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = D:\MySQL
datadir = D:\MySQL\data
port = 3306
server_id = 1
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 16M
read_rnd_buffer_size = 16M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
或者直接添加你需要修改的內容
[mysqld]
bind-address = 0.0.0.0
mysql沒有開啟遠程連接
一、改表法。
可能是你的帳號不允許從遠程登陸,只能在localhost登錄。這個時候只要在localhost的那臺電腦,登入mysql后,更改 "mysql" 數據庫里的 "user" 表里的 "host" 項,從"localhost"改把host更改為"%"
a. bin/mysql -uroot -p密碼
b. use mysql----->show tables;------>select host, user from user;
c. ?update user set host = '%' where user = 'root';
d. ?flush privileges;?
二、授權法。
例如,你想myuser使用mypassword從任何主機連接到mysql服務器的話。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
如果你想允許用戶xiefei從ip為172.22.254.1的主機連接到mysql服務器,并使用123456作為密碼 .
GRANT ALL PRIVILEGES ON *.* TO 'xiefei'@'172.22.254.1' IDENTIFIED BY '123456' WITH GRANT OPTION;
如果你在執行 GRANT 語句時遇到錯誤,可能是因為你的語法或者MySQL版本的問題。在MySQL 5.7及之后的版本中,GRANT 語句和 CREATE USER 語句是分開的,這意味著你不能直接在 GRANT 語句中創建用戶并設置密碼。你需要首先使用 CREATE USER 語句創建用戶,然后設置密碼,最后使用 GRANT 語句賦予權限。
-- 創建用戶 ?
CREATE USER 'root'@'%' IDENTIFIED BY 'smdc$#0510'; ?
??
-- 刷新權限,使創建用戶的操作立即生效 ?
FLUSH PRIVILEGES; ?
??
-- 賦予用戶所有權限 ?
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; ?
??
-- 再次刷新權限,使權限更改立即生效 ?
FLUSH PRIVILEGES;