mysql安装

创建用户:

groupadd mysql
useradd -m -g mysql mysql -s /sbin/nologin

下载压缩

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
tar xzvf mysql-8.0.16-linux-glibc2.12-x86_64.tar -C /usr/local/
mv /usr/local/mysql-8.0.16-linux-glibc2.12-x86_64 /usr/local/mysql

修改权限

chown mysql.mysql /usr/local/mysql/data

初始化数据库:

./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

配置文件

[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
socket = /usr/local/mysql/tmp/mysql.sock

[client]
default-character-set=utf8
socket= /usr/local/mysql/tmp/mysql.sock

[mysql]
default-character-set=utf8
socket= /usr/local/mysql/tmp/mysql.sock

chmod 777 /usr/local/mysql/tmp/

配置环境变量

vi /etc/profile
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
source /etc/profile

启动mysql:

cp mysql.server /etc/init.d/mysql
service mysql start

修改密码:

5.8
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

5.7
update mysql.user set authentication_string=password('vabesrb2oy') where user='root';

5.6:
update mysql.user set Password=password('vabesrb2oy') where user='root';

创建用户(8版本需要先创建用户才能授权)

create user 'lsc'@'%' identified by 'lsc';

创建仓库

create database blog DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
grant all on blog.* to 'lsc'@'%';
flush privileges;

查询用户信息

SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

报错:

./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
yum install -y libaio

posted @ 2019-12-11 13:46  薄荷少年郎微微凉  阅读(149)  评论(0编辑  收藏  举报