mysql_MariaDB_install

#!/bin/bash
cd /usr/local
tar zxvf mysql_mariadb-10.1.13-linux-x86_64.tar.gz 
mv mariadb-10.1.13-linux-x86_64 /usr/local/mysql
cd /usr/local/mysql


groupadd mysql
useradd -g mysql mysql
chown mysql:mysql -Rf  /usr/local/mysql
chmod +x -Rf /usr/local/mysql
cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
/usr/local/mysql/scripts/mysql_install_db --user=mysql 
cp  /usr/local/mysql/support-files/mysql.server    /etc/init.d/mysqld


#vim /etc/profile   编辑profile,将mysql的可执行路径加入系统PATH
#export PATH=/usr/local/mysql/bin:$PATH 
#source /etc/profile  使PATH生效
#mysqladmin -u root password 'xxxxxx' 设定root账号及密码
#mysql -uroot -p  使用root用户登录mysql
[none]>use mysql  切换至mysql数据库。
[mysql]>select user,host,password from user; --查看系统权限
[mysql]>drop user ''@'localhost'; --删除不安全的账户
[mysql]>drop user root@'::1';
[mysql]>drop user [email protected];


1)修改字符集为UTF8
#vi /etc/my.cnf
在[client]下面添加 default-character-set = utf8
在[mysqld]下面添加 character_set_server = utf8
修改完重启:#service  mysqld  restart 


2)增加错误日志
#vi /etc/my.cnf
在[mysqld]下面添加:
log-error = /usr/local/mysql/log/error.log
general-log-file = /usr/local/mysql/log/mysql.log
修改完重启:#service  mysql  restart 


3) 设置为不区分大小写,linux下默认会区分大小写。
#vi /etc/my.cnf
在[mysqld]下面添加:
lower_case_table_name=1
修改完重启:#service  mysql  restart  


chkconfig mysqld on


授权远程连接root
mysql -uroot -p
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'golomee' WITH GRANT OPTION;
FLUSH PRIVILEGES;

你可能感兴趣的:(linux)