linux安装MySQL
- 编辑此文件vim /etc/my.cnf
[mysql]
设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#跳过权限表校验
#skip-grant-tables
skip-name-resolve
#设置3306端口
port = 3306
#设置mysql的安装目录
basedir=/usr/local/mysql-5.7
#设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql-5.7/data
#允许最大连接数
max_connections=200
#服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
#创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M
添加mysql用户、mysql组
groupadd mysql
useradd -r -g mysql mysql
chown -R mysql:mysql /usr/local/mysql-5.7/
初始化mysql数据库,控制台会输出临时密码,请记下: root@localhost:xxxxxx
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
开启MySQL服务
./support-files/mysql.server start
cp support-files/mysql.server /etc/init.d/mysqld
service mysqld restart
mysql -u root -p
alter user 'root'@'localhost' identified by 'root';
添加MySQL变量
vim /etc/profile
export PATH=$JAVA_HOME/bin:/usr/local/mysql/bin:$PATH
source /etc/profile
登录MySQL设置远程访问账号:grant all privileges on . to 远程访问用户名@’%’ identified by ‘用户密码’;
grant all privileges on *.* to root@'%' identified by 'root';
flush privileges;