linux 下 mysql 修改密碼 修改 字元集 亂碼 資料庫 匯入 匯出 添加遠端存取

來源:互聯網
上載者:User

作業環境:fedora13 ;  mysql5

 

linux 下修改mysql 密碼格式如下如下 :

 

mysqladmin -u userName password newPassword

 

 

eg:

 

mysqladmin -u root password mynewpassword;

 

中文亂碼問題

修改mysql資料庫的設定檔

 

# vi /etc/my.cnf

在[mysqld]下添加
default-character-set=utf8

若有[client]在[client]下添加
default-character-set=utf8

 

3. 重啟mysql

# service mysqld restart 

 

4.登入mysql看看修改成功否

# mysql

如果需要使用者名稱和密碼則

# mysql -uroot -proot
mysql> show variables like 'character_set_%';

mysql> show variables like 'collation_%';

 

 

注意:如果自己有初始化資料庫的檔案,要確保檔案的編碼的正確性,通過自己的實踐遇到了 在windows上用mysql front 匯出utf8 格式的資料庫 的".sql"檔案,如果直接用記事本開啟複製上面的資訊後粘貼到 命令列,則用web程式顯示出來有可能仍是亂碼。

 

最好的辦法就是 通過mysql 的命令 匯出 資料庫 ,而後再 匯入

 

mysql windows 匯出命令 執行個體

 

C:/Program Files/MySQL/MySQL Server 5.1/bin>mysqldump -uroot -proot test > d:/test.sql

 

linux mysql 匯入上面的檔案 執行個體

 

mysql 要匯入的資料庫 < 要到如的檔案名稱

 

# mysql mysqltestDB < /usr/test.sql

 

 

 

如拒絕訪問,則說明是存取權限問題 參考如下

java.sql.SQLException: null,  message from server: "Host 'xxx' is not allowed to connect to this MySQL server":

 

 

你想user使用userPassword從任何主機串連到mysql伺服器的話。
GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'userPassword' WITH GRANT OPTION;
如果你想允許使用者user從ip為192.168.1.15的主機串連到mysql伺服器,並使用userPassword作為密碼
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.2.15' IDENTIFIED BY 'userPassword' WITH GRANT OPTION;

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.