MySQL(一)安裝配置

來源:互聯網
上載者:User

標籤:ble   start   tables   地址   生效   sele   rest   關閉   使用者管理   

1、安裝配置
cd d:\mysql\bin
mysqld --initialize--insecure # 初始化伺服器
mysqld # 啟動伺服器
mysqld --install # 註冊服務
mysqld --remove # 刪除服務
net start mysql # 啟動服務
net stop mysl # 關閉服務
mysql -h 10.0.0.3 -u root -p xxxx # 登陸伺服器
2、使用者管理
增:
create user ‘使用者名稱‘@‘IP地址‘ identified by ‘密碼‘;
刪:
drop user ‘使用者名稱‘@‘IP地址‘;
改:
rename user ‘使用者名稱‘@‘IP地址‘; to ‘新使用者名稱‘@‘IP地址‘;;
set password for ‘使用者名稱‘@‘IP地址‘ = Password(‘新密碼‘)
查:
select * from mysql.user\G; # 查看所有賬戶資訊
就是一張普通的表,支援 delete update 等直接操作
3、許可權管理
增:
grant 許可權 on 資料庫.表 to ‘使用者‘@‘10.0.0.%‘ -- 授權
刪:
revoke 許可權 on 資料庫.表 from ‘使用者‘@‘IP地址‘ -- 取消許可權
改:
flush privileges # 立即生效
grant all on *.* to ‘*‘@‘%‘;
查:
show grants for [email protected]; -- 查看許可權
4、忘記密碼
# 啟動免授權服務端
mysqld --skip-grant-tables

# 用戶端
mysql -u root -p

# 修改使用者名稱密碼
update mysql.user set authentication_string=password(‘666‘) where user=‘root‘;
flush privileges;
5、資料庫操作
增:
create database 庫名 charset utf8;
# 建立資料庫 MyTest,指定字元集 utf8
刪:
drop database 庫名;

改:
-- 為注釋
查:
show databases;
6、Ubuntu互聯win
win上無法串連的問題:
查看運行連接埠
sudo netstat -tap | grep mysql

發現
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 7843/mysqld

更改設定檔
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
/bind 尋找到43行 bind-address = 127.0.0.1 注釋掉

重啟服務
sudo service mysql restart

OK 解決問題

MySQL(一)安裝配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.