本文目錄一覽:
服務器mysql怎麼配置才能遠程連接
設置mysql數據庫遠程連接:
Windows系統
1、 停止mysql的服務。
2、 進入命令窗口,然後進入MySQL的安裝目錄,比如我的安裝目錄是c:\mysql,進入c:\mysql\bin
3、 進入mysql數據庫服務器
c:\mysql\binmysql –u root –p hkgt123
4、 選中數據庫mysql :use mysql
5、 查詢mysql數據庫中的用戶:
Select host,user,password from mysql;
6、 授權給root用戶可以從任何主機使用密碼為’hkgt123’登錄MYSQL數據庫:
GRANT ALL PRIVILEGES ON *.* TO root@’%’ IDENTIFIED BY ‘hkgt123’ WITH GRANT OPTION;
7、 提交:commit;
8、 刷新權限:flush privileges;
用MysQL怎麼進行遠程連接數據庫
MySQl遠程連接數據庫有兩種方法,具體如下:
改表法。 在localhost登入mysql後,更改 “MySql” 數據庫中的 “User” 表裡的 “Host”選項,將”localhost”對應的值改為”%”,具體代碼如圖所示:
2.授權法。 若MyUser想要使用mypassword(用戶密碼)從任何主機連接到mysql服務器則可以使用此方法,具體步驟如下圖所示。
3.按照上述改法,保存後重啟即可生效。
拓展資料:
數據庫(Database)是按照數據結構來組織、存儲和管理數據的倉庫,它產生於距今六十多年前,隨着信息技術和市場的發展,特別是二十世紀九十年代以後,數據管理不再僅僅是存儲和管理數據,而轉變成用戶所需要的各種數據管理的方式。
2.數據庫有很多種類型,從最簡單的存儲有各種數據的表格到能夠進行海量數據存儲的大型數據庫系統都在各個方面得到了廣泛的應用。
3.在信息化社會,充分有效地管理和利用各類信息資源,是進行科學研究和決策管理的前提條件數據庫技術是管理信息系統、辦公自動化系統、決策支持系統等各類信息系統的核心部分,是進行科學研究和決策管理的重要技術手段。
4.數據庫是一個單位或是一個應用領域的通用數據處理系統,它存儲的是屬於企業和事業部門、團體和個人的有關數據的集合。數據庫中的數據是從全局觀點出發建立的,按一定的數據模型進行組織、描述和存儲。
5.其結構基於數據間的自然聯繫,從而可提供一切必要的存取路徑,且數據不再針對某一應用,而是面向全組織,具有整體的結構化特徵。
參考資料:數據庫_百度百科
怎麼配置mysql數據庫配置文件
一、mysql_install_db說明
當MySQL的系統庫(mysql系統庫)發生故障或需要新加一個mysql實例時,需要初始化mysql數據庫。
需要使用的命令:/usr/local/mysql/bin/mysql_install_db
#/usr/local/mysql/bin/mysql_install_db –help 可以查看幫助信息如下
Usage: /usr/local/mysql/bin/mysql_install_db [OPTIONS]
–basedir=path The path to the MySQL installation directory.
–cross-bootstrap For internal use. Used when building the MySQL system
tables on a different host than the target.
–datadir=path The path to the MySQL data directory.
–force Causes mysql_install_db to run even if DNS does not
work. In that case, grant table entries that normally
use hostnames will use IP addresses.
–ldata=path The path to the MySQL data directory.
–rpm For internal use. This option is used by RPM files
during the MySQL installation process.
–skip-name-resolve Use IP addresses rather than hostnames when creating
grant table entries. This option can be useful if
your DNS does not work.
–srcdir=path For internal use. The directory under which
mysql_install_db looks for support files such as the
error message file and the file for popoulating the
help tables.
–user=user_name The login username to use for running mysqld. Files
and directories created by mysqld will be owned by this
user. You must be root to use this option. By default
mysqld runs using your current login name and files and
directories that it creates will be owned by you.
All other options are passed to the mysqld program
除了支持以上的參數,還支持mysqld的參數。
二、舉例:
本文以新加一個mysql實例為例。例如服務器上已經安裝了3306端口的mysql服務,需要再啟一個3308端口的mysql服務。
假設mysql安裝在/usr/local/mysql路徑下,找一個磁盤空間剩餘比較大的盤,如/data1,把3308端口的mysql的數據保存在/data1下
#mkdir /data1/mysql_3308
#mkdir /data1/mysql_3308/data
#chown -R mysql:mysql /data1/mysql_3308
複製一個mysql配置文件my.cnf到/data1/mysql_3308目錄下
#vi /data1/mysql_3308/my.cnf
修改配置文件,將端口和相關目錄的都改為新的設置,如下:
[client]
character-set-server = utf8
port = 3308
socket = /tmp/mysql_3308.sock
[mysqld]
user = mysql
port = 3308
socket = /tmp/mysql_3308.sock
basedir = /usr/local/mysql
datadir = /data1/mysql_3308/data
log-error = /data1/mysql_3308/mysql_error.log
pid-file = /data1/mysql_3308/mysql.pid
……其他略
確保配置文件無誤。
運行下面命令進行數據庫的初始化:
#/usr/local/mysql/bin/mysql_install_db –defaults-file=/data1/mysql_3308/my.cnf –datadir=/data1/mysql_3308/data
完成後新的3308數據庫就初始化好了,如果有報錯,則按照報錯的提示查看報錯日誌,一般情況下都是my.cnf配置文件的問題,修正後即可。
三、啟動新mysql
啟動3308端口的mysql服務
#/usr/local/mysql/bin/mysqld_safe –defaults-file=/data1/mysql_3309/my.cnf
檢查是否啟動
#ps aux|grep mysql
如果有3308字樣說明已經啟動成功
可將啟動命令加入/etc/rc.local隨服務器啟動
新加的mysql沒有設置root密碼,可以通過下面命令設置root密碼:
#/usr/local/mysql/bin/mysqladmin -S /tmp/mysql_3308.sock -u root password ‘new-password’
原創文章,作者:GVRUP,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/316704.html