下载相应的mysql安装包后
cp /home/hdkg/soft/mysql-8.0.11-linux-glibc2.12-x86_64.tar/usr/local/
tar xvf mysql-8.0.11-linux-glibc2.12-x86_64.tar
tar zxvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
mv mysql-8.0.11-linux-glibc2.12-x86_64mysql
添加用户和组
groupadd mysql
useradd -g mysql mysql
cd /usr/local/mysql/
mkdir /data/
chown -R mysql:mysql .
cp /home/hdkg/soft/my.cnf /etc/my.cnf
如果/etc/my.cnf之前存在,就不拷贝了,没有就自己创建一个吧 ,修改其中
[mysqld]
lower_case_table_names=1
event_scheduler=1
max_connections=500
Datadir=/usr/local/mysql/data
Basedir=/usr/local/mysql
socket = /usr/local/mysql/data/mysql.sock
[client]
socket = /usr/local/mysql/data/mysql.sock
保存my.cnf
/bin/mysqld--defaults-file=/etc/my.cnf –initialize
有初始化密码
或者
/bin/mysqld--defaults-file=/etc/my.cnf --initialize-insecure
无初始密码建议这个
我们执行下面这个没有初始密码的
bin/mysqld --initialize-insecure --user=mysql--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
然后
bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
然后
Cp -r /bin/support-files/mysql.server /etc/init.d/mysqld
然后
service mysqld start
然后
service mysqld status
然后
vi /etc/profile
前面追加客户端的位置
export PATH=/usr/local/mysql/bin:$PATH
然后
source /etc/profile
然后
mysql -uroot -p
回车
根据前面的操作,有密码输入密码,没有直接回车
11
配置mysql自动启动
# chmod 755 /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on
创建用户及修改 root用户权限:
use mysql;
CREATE USER 'test'@'%' IDENTIFIEDWITH mysql_native_password BY 'test2007';
flush privileges;
grant all on *.* to 'test'@'%' WITH GRANT OPTION;
flush privileges;
alter user 'root'@'localhost' identified with mysql_native_password by'root';
flush privileges;
update user set host=’%’where user=’root’;
flush privileges’
下面是my.cnf文件 样例 红色部分参数是为了解决,客户端还停留在5.6.x-5.7.x版本 密码验证的问题。还有字符集的问题。
my.cnf 文件基本内容(红色部分为要添加部分)
# For advice on how to change settingsplease see
#http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's atemplate which will be copied to the
# *** default location during install, andwill be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
socket = /usr/local/mysql/data/mysql.sock
[mysqld]
lower_case_table_names=1
event_scheduler=1
max_connections=500
default_authentication_plugin=mysql_native_password
slow_query_log = ON
slow_query_log_file =/usr/local/mysql/data/slow.log
long_query_time = 1
character_set_server=utf8
skip-host-cache
skip-name-resolve
# Remove leading # and set to the amount ofRAM for the most important data
# cache in MySQL. Start at 70% of total RAMfor dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a veryimportant data integrity option: logging
# changes to the binary log betweenbackups.
# log_bin
log_bin=/usr/local/mysql/mysql-bin
# These are commonly set, remove the # andset as required.
basedir = /usr/local/mysql/
datadir = /usr/local/mysql/data/
# port = .....
server_id = 178
#socket = /var/lib/mysql/mysql.sock
socket = /usr/local/mysql/data/mysql.sock
# Remove leading # to set options mainly usefulfor reporting servers.
# The server defaults are faster fortransactions and fast SELECTs.
# Adjust sizes as needed, experiment tofind the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
解决客户端没有8.0 加密插件方案
[mysqld]
default_authentication_plugin=mysql_native_password
下面是grep 查询高亮显示
可以通过设置GREP_OPTIONS 为'--color=auto'来自动为匹配部分着色
也可以通过设置GREP_COLOR的值来指定颜色
下面是部分颜色的值
30 black
31 red
32 green
33 yellow
34 blue
35 purple
36 cyan
37 white