昨天臨下班的時候,在個人阿里雲上面試裝了PostgreSQL,可後來想一想,彷佛沒什麼必要使用他。主要是Navicat使用起來加自增key的時候,沒有像MySQL那麼方便啦。mysql
由於公司用的已是MySQL了,就一條道走到底好了。面試
CentOS上彷佛更推薦使用MariaDB的樣子。因而就這樣愉快地決定就用MariaDB。sql
使用vi編輯器建立並編輯centos
vi /etc/yum.repos.d/MariaDB.repo
內容你能夠在官網找到 https://downloads.mariadb.org/mariadb/repositories/socket
由於我是32位版的CentOS6.5編輯器
因此使用的是工具
# MariaDB 10.0 CentOS repository list - created 2015-04-25 06:46 UTC # http://mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.0/centos6-x86 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
ESC=>:wq=>Enter阿里雲
保存退出url
yum install MariaDB-server MariaDB-client
移除默認目錄spa
rm -rf /var/lib/mysql
建立自定義目錄
mkdir /usr/local/mariadb
用vi打開並編輯配置文件
vi /etc/my.cnf.d/mysql-clients.cnf
內容參考
[client] port = 3306 socket = /usr/local/mariadb/mysql.sock
還有另外一個
vi /etc/my.cnf.d/server.cnf
[mysqld] port = 3306 datadir = /usr/local/mariadb socket = /usr/local/mariadb/mysql.sock skip-external-locking key_buffer_size = 256M max_allowed_packet = 64M table_open_cache = 256 sort_buffer_size = 1M read_buffer_size = 1M read_rnd_buffer_size = 4M myisam_sort_buffer_size = 64M thread_cache_size = 8 query_cache_size= 16M thread_concurrency = 8 log-bin=mysql-bin binlog_format=mixed server-id = 1
lower_case_table_names = 0
mysql_install_db --defaults-file=/etc/my.cnf --datadir=/usr/local/mariadb/ --user=mysql
service mysql start
start、stop、restart
mysqladmin -u root password "mypassword"
注意修改本身密碼
mysql -uroot -p
root可從任何IP登陸
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypwd' WITH GRANT OPTION;
root可從指定IP登錄IP:'192.168.1.2'
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.2' IDENTIFIED BY 'mypwd' WITH GRANT OPTION; mysql>FLUSH RIVILEGES
操做完畢以後,使用命令flush privileges;來啓用
而後你能夠經過Navicat之類的工具鏈接,直接操做mysql.user表就能修改帳號,最後別忘了用mysql>flush privileges;來啓用修改哦。