×ðÁú¿­Ê±¹ÙÍøµÇ¼

ÉèÖÃLinuxϵͳÒÔÖ§³ÖÂþÑÜʽÊý¾Ý¿â¿ª·¢

ÉèÖÃlinuxϵͳÒÔÖ§³ÖÂþÑÜʽÊý¾Ý¿â¿ª·¢

СÐò:

Ëæ×Å»¥ÁªÍøµÄѸÃÍÉú³¤£¬Êý¾ÝÁ¿¼±¾çÔöÌí£¬¶ÔÊý¾Ý¿âµÄÐÔÄܺÍÀ©Õ¹ÐÔÒªÇóÒ²Ô½À´Ô½¸ß¡£ÂþÑÜʽÊý¾Ý¿â³ÉΪÁËÓ¦¶ÔÕâÒ»ÌôÕ½µÄ½â¾ö¼Æ»®¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚLinuxϵͳÏÂÉèÖÃÂþÑÜʽÊý¾Ý¿âÇéÐΣ¬ÒÔÖ§³ÖÂþÑÜʽÊý¾Ý¿â¿ª·¢¡£

Ò»¡¢×°ÖÃLinuxϵͳ

Ê×ÏÈ£¬ÎÒÃÇÐèҪװÖÃÒ»¸öLinux²Ù×÷ϵͳ¡£³£¼ûµÄLinux¿¯ÐаæÓÐUbuntu¡¢CentOS¡¢DebianµÈ£¬ÆäÖÐUbuntuÊÇÒ»¸öºÜÊÇÊ¢ÐеÄÑ¡Ôñ¡£¿ÉÒÔ´Ó¹Ù·½ÍøÕ¾ÏÂÔؾµÏñÎļþ£¬²¢Æ¾Ö¤¹Ù·½Îĵµ¾ÙÐÐ×°Öá£

¶þ¡¢×°ÖúÍÉèÖÃÊý¾Ý¿âÖÎÀíϵͳ

Ê×ÏÈ×°ÖÃÒ»¸öÊý¾Ý¿âÖÎÀíϵͳ£¬ÈçMySQL»òPostgreSQL¡£ÒÔUbuntuΪÀý£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî×°ÖÃMySQL£º

sudo apt-get update
sudo apt-get install mysql-server

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³Éºó£¬Æô¶¯Êý¾Ý¿âЧÀͲ¢ÉèÖÿª»ú×ÔÆô¶¯£º

sudo systemctl start mysql
sudo systemctl enable mysql

µÇ¼ºó¸´ÖÆ

ÉèÖÃÊý¾Ý¿âÖÎÀíϵͳµÄ²ÎÊý£¬ÒÔ˳ӦÂþÑÜʽÇéÐΡ£·­¿ªMySQLµÄÉèÖÃÎļþ/etc/mysql/mysql.conf.d/mysqld.cnf£¬ÐÞ¸ÄÒÔϲÎÊý£º

bind-address = 0.0.0.0

µÇ¼ºó¸´ÖÆ

¸Ã²ÎÊý½«ÔÊÐíÆäËûÅÌËã»úͨ¹ýÍøÂçÅþÁ¬µ½¸ÃÊý¾Ý¿âÖÎÀíϵͳ¡£

ÖØмÓÔØMySQLµÄÉèÖÃÎļþÒÔʹ¸ü¸ÄÉúЧ£º

sudo systemctl reload mysql

µÇ¼ºó¸´ÖÆ

Èý¡¢ÉèÖÃÖ÷½ÚµãºÍ´Ó½Úµã

ÔÚÂþÑÜʽÊý¾Ý¿âÖУ¬Í¨³£±£´æÖ÷½ÚµãºÍ´Ó½ÚµãÁ½ÖÖ½ÇÉ«¡£Ö÷½ÚµãÓÃÓÚ´¦ÀíдÈë²Ù×÷ºÍÊý¾ÝµÄÖ÷ÒªÅÌÎÊ£¬¶ø´Ó½ÚµãÓÃÓÚ¸´ÖÆÖ÷½ÚµãµÄÊý¾Ý£¬²¢´¦Àí¶ÁÈ¡²Ù×÷ÇëÇó¡£

Ê×ÏÈ£¬ÉèÖÃÖ÷½Úµã¡£µÇ¼µ½MySQL¿ØÖÆ̨£º

mysql -u root -p

µÇ¼ºó¸´ÖÆ

½¨ÉèÒ»¸öеÄÊý¾Ý¿âÓû§£¬²¢ÎªÆäÊÚȨÖ÷½ÚµãµÄ¶ÁдȨÏÞ£º

CREATE USER 'user'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

µÇ¼ºó¸´ÖÆ

½ÓÏÂÀ´£¬ÉèÖôӽڵã¡£ÔÚ´Ó½ÚµãÉÏÖ´ÐÐÓëÖ÷½ÚµãÏàͬµÄ²Ù×÷£¬½¨ÉèÒ»¸öÓëÖ÷½ÚµãÏàͬµÄÓû§£¬²¢½«¸ÃÓû§µÄȨÏÞÉèÖÃΪֻ¶ÁȨÏÞ£º

CREATE USER 'user'@'%' IDENTIFIED BY 'password';
GRANT SELECT, SHOW VIEW ON *.* TO 'user'@'%';
FLUSH PRIVILEGES;

µÇ¼ºó¸´ÖÆ

ËÄ¡¢ÉèÖò¢²âÊÔ¸´ÖÆ

ÔÚÂþÑÜʽÊý¾Ý¿âÖУ¬´Ó½Úµãͨ¹ý¸´ÖÆÖ÷½ÚµãµÄÊý¾ÝÀ´ÊµÏÖÊý¾ÝµÄÒ»ÖÂÐÔ¡£ÏÂÃæÏÈÈÝÔõÑùÉèÖò¢²âÊÔ¸´ÖÆ¡£

ÔÚÖ÷½ÚµãÉÏ£¬±à¼­MySQLµÄÉèÖÃÎļþ/etc/mysql/mysql.conf.d/mysqld.cnf£¬Ìí¼ÓÒÔϲÎÊý£º

server-id = 1
log_bin = /var/log/mysql/binlog

µÇ¼ºó¸´ÖÆ

ÕâЩ²ÎÊý½«ÆôÓöþ½øÖÆÈÕÖ¾¼Í¼£¬ÓÃÓÚ´æ´¢Ö÷½ÚµãµÄÊý¾Ý¸ü¸Ä¼Í¼¡£

ÖØÆôÖ÷½ÚµãµÄMySQLЧÀÍ£º

sudo systemctl restart mysql

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÔÚ´Ó½ÚµãÉÏ£¬±à¼­MySQLµÄÉèÖÃÎļþ/etc/mysql/mysql.conf.d/mysqld.cnf£¬Ìí¼ÓÒÔϲÎÊý£º

server-id = 2
relay-log = /var/log/mysql/relaylog

µÇ¼ºó¸´ÖÆ

ÕâЩ²ÎÊý½«Ê¹´Ó½ÚµãÄܹ»ÎüÊպ͸´ÖÆÖ÷½ÚµãµÄÊý¾Ý¸ü¸Ä¡£

ÖØÆô´Ó½ÚµãµÄMySQLЧÀÍ£º

sudo systemctl restart mysql

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÔÚÖ÷½ÚµãÉÏ£¬Ê¹ÓÃÒÔÏÂÏÂÁÉèÒ»¸ö²âÊÔÊý¾Ý¿â£¬²¢²åÈëһЩÊý¾Ý£º

CREATE DATABASE test;
USE test;
CREATE TABLE employees (
    id INT PRIMARY KEY,
    name VARCHAR(100)
);
INSERT INTO employees VALUES(1, 'John');
INSERT INTO employees VALUES(2, 'Jane');

µÇ¼ºó¸´ÖÆ

ÔÚ´Ó½ÚµãÉÏ£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¼ì²éÊý¾ÝÊÇ·ñÒÑÀֳɸ´ÖÆ£º

USE test;
SELECT * FROM employees;

µÇ¼ºó¸´ÖÆ

ÈôÊÇ´Ó½ÚµãÏÔʾÁËÓëÖ÷½ÚµãÏàͬµÄÊý¾Ý£¬ÔòÌåÏÖ¸´ÖÆÀֳɡ£

×ܽá:

ͨ¹ý±¾ÎĵÄÖ¸µ¼£¬ÎÒÃÇÒѾ­ÀֳɵØÉèÖÃÁËLinuxϵͳÒÔÖ§³ÖÂþÑÜʽÊý¾Ý¿â¿ª·¢¡£ÔÚÕâ¸öÉèÖÃÀú³ÌÖУ¬ÎÒÃÇ×°ÖÃÁËÊý¾Ý¿âÖÎÀíϵͳ¡¢ÉèÖÃÁËÖ÷½ÚµãºÍ´Ó½Úµã£¬²¢²âÊÔÁËÊý¾Ý¸´ÖƵĹ¦Ð§¡£ÂþÑÜʽÊý¾Ý¿âÄܹ»×ÊÖúÎÒÃÇÓ¦¶Ôº£Á¿Êý¾ÝµÄÌôÕ½£¬Ìá¸ßÊý¾Ý¿âϵͳµÄÐÔÄܺÍÀ©Õ¹ÐÔ¡£

²Î¿¼×ÊÁÏ:

MySQL¹Ù·½Îĵµ: https://dev.mysql.com/doc/

PostgreSQL¹Ù·½Îĵµ: https://www.postgresql.org/docs/

ÒÔÉϾÍÊÇÉèÖÃLinuxϵͳÒÔÖ§³ÖÂþÑÜʽÊý¾Ý¿â¿ª·¢µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

13452372176

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ