当前位置:网站首页>mysql8 installation under linux
mysql8 installation under linux
2022-07-30 19:37:00 【m0_67401382】
mysql8 installation under linux
Download the installation package
Download address: https://dev.mysql.com/downloads/mysql/
Upload to the linux server or download directly on the server through get
Unzip the installation package
Unzip the installation package just downloaded and rename the directory to: mysql8
Directory path: /data/mysql8
Create data directory: /data/mysql8/data
Create mysql user and give permission
groupadd mysql
useradd -g mysql mysql
mkdir /var/lib/mysql
mkdir /data/mysql8/log
touch /data/mysql8/log/mysql.log
chown -R mysql.mysql /data/mysql8
chown -R mysql.mysql /var/lib/mysql
Initialize data
Enter the decompressed bin directory: /data/mysql8/bin and execute the following command (note: the root password printed on the console when the command below is executed needs to be written down and used later. For example, [email protected]: password)
./mysqld --user=mysql --basedir=/data/mysql8 --datadir=/data/mysql8/data/ --initializ
Note: Commands not found by "libaio.so.1" will be reported here.Install and solve by yum install libaio*, then re-execute the above command
Modify configuration
After initialization, the configuration file /etc/my.cnf will be generated.Modify it with vi /etc/my.cnf
The main increase configuration is as follows:
basedir=/data/mysql8
datadir=/data/mysql8/data
#Modify the directory to solve the problem that localhost cannot beConnection problems
socket=/var/lib/mysql/mysql.sock
[mysqld_safe]
log-error=/data/mysql8/log/mysql.log
pid-file=/data/mysql18/log/mysql.pid
[client]
#Modify the directory to solve the problem that localhost cannot be connected
socket=/var/lib/mysql/mysql.sock
The complete configuration is as follows:
[mysqld]basedir=/data/mysql8datadir=/data/mysql8/datasocket=/var/lib/mysql/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# lower_case_table_names=1character_set_server=utf8mb4init_connect='SET collation_connection=utf8mb4_unicode_ci'init_connect='SET NAMES utf8mb4'collation-server=utf8mb4_unicode_ciskip-character-set-client-handshake# Settings user and group are ignored when systemd is used.# If you need to run mysqld under a different user or group,# customize your systemd unit file for mariadb according to the# instructions in http://fedoraproject.org/wiki/Systemd[mysqld_safe]log-error=/data/mysql8/log/mysql.logpid-file=/data/mysql18/log/mysql.pid## include all files from the config directory#!includedir /etc/my.cnf.d[client]default-character-set=utf8mb4#Modify the directory to solve the problem that localhost cannot be connectedsocket=/var/lib/mysql/mysql.sock[mysql]default-character-set=utf8mb4
Set environment variables
vi /etc/profile
Add at the end:
export MYSQL_PATH=/data/mysql8/bin/
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/data/mysql8/bin'
Finally, remember to execute: source /etc/profile
Register mysql as a service
cp /data/mysql8/support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
Add mysql to startup
chkconfig --add mysql
chkconfig --list
Note: If the result of the chkconfig --list command mysql items 3 4 5 are all on, it is successful, otherwise it can be repaired by chkconfig --level 345 mysql onThe
Start mysql service
service mysql start
Change root account password
Log in to myql: mysql -hlocalhost -uroot -p
Enter the initialized password above
Modify the root default password: ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password'
Note:Must be modified, no modification is allowed to perform other operations
At this point, the installation is complete. If you need to connect to other machines, you need to create a user and give permissions, refer to the "other commands" below as needed.
Other commands
Create database: CREATE DATABASE database name;
Create user: create user 'user name' identified by 'password'
Set root user remote access: first use mysql; then update user set host='%' where user='root';
Give database permissions: grant all privileges on database name.* to 'utest'@'%';
Refresh permissions: flush privileges; remember to use this command to refresh after modifying permissionslower permissions
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
猜你喜欢
随机推荐
VBA 连接Access数据库和Excle
刷题记录----字符串
【MindSpore】多卡训练保存权重问题
The 17th "Revitalization Cup" National Youth Vocational Skills Competition - Computer Programmers (Cloud Computing Platform and Operation and Maintenance) Participation Review and Summary
WEBSOCKETPP使用简介+demo
What is the value of biomedical papers? How to translate the papers into Chinese and English?
【MindSpore】用coco2017训练Model_zoo上的 yolov4,迭代了两千多batch_size之后报错,大佬们帮忙看看。
redis
nlohmann json 使用指南【visual studio 2022】
Difference between Object and Map
MindSpore:自定义dataset的tensor问题
Another company interview
MindSpore:【MindSpore1.1】Mindspore安装后验证出现cudaSetDevice failed错误
win2003下FTP服务器如何搭建
The technology is very powerful, do you still need to "manage up"?
电脑死机的时候,发生了什么?
阿里云武林头条活动分享
MySQL性能优化(硬件,系统配置,表结构,SQL语句)
Range.CopyFromRecordset method (Excel)
MindSpore:【JupyterLab】按照新手教程训练时报错