Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Install mysql in linux environment

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Mysql learning

Install mysql on Linux

1. Download the installation package Server version: 5.7.28 MySQL Community Server (GPL)

Download path: https://dev.mysql.com/downloads/mysql/

Get mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz and mysql-test-5.7.28-linux-glibc2.12-x86_64.tar.gz from mysql-5.7.28-linux-glibc2.12-x86_64.tar. Test is not used yet, just upload and install: mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz

Extract the file: tar xzvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz / usr/local/

Rename file: mv mysql-5.7.28-linux-glibc2.12-x86_64 mysql

2, install

First check if there are any mysql users: cat / etc/group | grep mysql

Cat / etc/passwd | grep mysql

If none, add the mysql user.

Groupadd mysql

Useradd-r-g mysql mysql

Mkdir / usr/local/mysql/data

Chown-R mysql:mysql / usr/local/mysql

Configuration / etc/my.cnf file:

[mysqld]

Datadir=/usr/local/mysql/data

Basedir=/usr/local/mysql

Sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

Symbolic-links=0

Max_connections=400

Innodb_file_per_table=1

# Table names are not clear in case, and the sensitivity is

Lower_case_table_names=1

User=mysql

Socket=/mysqllog/mysql.sock

Character-set-server=utf8

# skip-grant-tables

[mysql]

Default-character-set=utf8

Socket=/mysqllog/mysql.sock

[mysqld_safe]

Log-error=/mysqllog/mysqld.log

Pid-file=/mysqllog/mysqld.pid

# datadir=/usr/local/mysql/data

[cient]

Port=3306

Socket=/mysqllog/mysql.sock

Create a log folder

Mkdir mysqllog

Vi mysqld.log New mysqld.log

Chown-R mysql:mysql / mysqllog

Chmod 755 / mysqllog/mysqld.log

Initialize:

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

Add soft link

Ln-s / usr/local/mysql/support-files/mysql.server / etc/init.d/mysql

Ln-s / usr/local/mysql/bin/mysql / usr/bin/mysql

Restart the service

Service mysql restart

Password deletion / etc/init.d/my.cnf add skip-grant-tables

Then log in to mysql directly to change the password.

Update mysql.user set authentication_string=password ('root123') flush privileges after where user='root'; execution

Delete skip-grant-tables again

Restart the service mysql

Connect mysql

Enter: mysql-u root-p

Input: root123

Show databases

Use mysql

Add remote access

Open an IP

Grant all privileges on. To 'root'@'192.168.0.1' identified by' password' with grant option

Turn on all

Grant all privileges on. To 'root'@'%' identified by' password' with grant option

Remember to refresh the mysql mechanism

Flush privileges

Quit

Try to connect remotely to access... If you cannot access the mysql server, the firewall may open the unreleased port 3306.

Firewall release add

/ etc/sysconfig/iptables

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 3306-j ACCEPT

Then execute service iptables restart

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report