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

Detailed introduction of mysql installation and configuration steps

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly gives you a brief introduction to the steps of mysql installation and configuration. You can check the relevant professional terms on the Internet or find some related books to supplement them. We will not dabble here, so let's go straight to the topic. I hope this article on the steps of mysql installation and configuration can bring you some practical help.

Mysql installation

Port number: 3306

Mysql official website http://mirrors.sohu.com/mysql/

Usually install mysql using the source package, but its compilation takes a long time, the experiment here is a binary compilation-free package; compilation-free package with the word glibc, the source package is the package name (such as mysql) plus version number plus suffix, now most of the online use of mysql-5.0 and mysql-5.1, of which version 5.6 is stable. To install mysql, you need to distinguish between platform and whether the machine is 32-bit or 64-bit.

Uname-I

I386 means 32-bit package to download i686, x86'64, 64-bit.

. / scripts/mysql_install-db,--user indicates the owner of the database,-- datadir indicates where the database is installed, and the partition that is usually placed in a large space will show two Ok at last to indicate that the installation is successful.

The log of Mysqld is in / data/mysql. If you can't start it, you can check the error day to solve the problem. This error log is usually the hostname .err.

Check the mysql compilation parameter: cat/usr/local/mysql/bin/mysqlbug | grep configure

With regard to the establishment of mysql users, it is to improve security. If the mysql service is hacked, then it can only get mysql permissions, not root permissions.

I. Classification of Mysql installation methods

1. Source package installation

Since MySQL5.5 is going to be installed with cmake, it can no longer be compiled and installed with. / configure. Let's take a look at the installation directory of mysql5.6.12. From the installation directory below, we can see that there is no configure file in it. I

Let's talk about cmake.

One of the important features of cmake is its compilation function independent of the source code (out-of-source), that is, the compilation can be carried out in another specified directory rather than the source directory, which ensures that the source directory will not be affected by any one compilation, so multiple different compilations can be performed on the same source tree, such as for different platforms.

two。 General binary package installation

General binary package installation instructions the package has been compiled, we do not need to recompile, we just need to decompress, a simple configuration can be run!

3.RPM package installation

This installation we do not explain too much, we should all know! All right, let's explain these three installations in detail!

Steps:

Initialize:

Yuminstall-y wget

Cd / usr/local/src / / wget will be placed in this file in the future

Wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-i686-glibc23.tar.gz

Tar-zxvf mysql-5.1.73-linux-i686-glibc23.tar.gz

Mvmysql-5.1.73-linux-i686-glibc23 / usr/local/mysql / / move position

Cd/usr/local/mysql

Useradd-s/sbin/nologin mysql / / establish a mysql user

Mkdir-p/data/mysql / / database files will be placed in this directory

Chown-Rmysql:mysql / data/mysql / / change permissions

. / scripts/mysql_install_db--user=mysql-- datadir=/data/mysql / / initialize

Echo $? / / showing 0 indicates success

Configure mysql:

Cpsupport-files/my-large.cnf / etc/my.cnf / / copy configuration file

Cpsupport-files/mysql.server / etc/init.d/mysqld / / copy startup script

Vim/etc/init.d/mysqld / / modify startup script

The datadir=/data/mysql / / configuration file is added to the directory where the database is stored, and the

Chkconfig-addmysqld / / add mysqld to the system service item

Chkconfig mysqldon / / Boot starts msyqld

Compile and install mysql

# there are many deficiencies in version 5.6 during testing

Cd / usr/local/src

Yum install-ygcc gcc-c++ / / packages required for compilation

Yum install-yncurses-devel / / packages required for compilation

Yum install-yopenssl openssl-devel / / cmake requires ssl support

Wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.51.tar.gz

# the URL is often updated. If you can't, use http://mirrors.sohu.com and open it step by step.

Tar-zxvfmysql-5.5.49.tar.gz

Cd mysql-5.5.49

Yum install-ycmake

Cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/mysql/data-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS:STRING=all-DWITH_DEBUG=0-DWITH_SSL=yes-DWITH_READLINE=1-DENABLED_LOCAL_INFILE=1

Echo $?

Make # time is about 10 minutes

Echo $?

Make install

Echo $?

Cd/usr/local/mysql/

Useradd-s/sbin/nologin mysql

Chown-Rmysql:mysql / usr/local/mysql/

Mkdir-p/mysql/data

. / scripts/mysql_install_db--user=mysql-- datadir=/mysql/data

Chown-R root / usr/local/mysql

Chown-R mysqldata

Cpsupport-files/my-medium.cnf / etc/my.cnf / / copy the mysql main configuration file

Bin/mysqld_safe--user=mysql &

Cpsupport-files/mysql.server / etc/init.d/mysqld

Chmod + x/etc/init.d/mysqld

/ etc/init.d/mysqldstart

Set root password

Enter mysql

Mysqladmin-uroot password 'aminglinux.com' / / mysqladmin has declared the variable PATH

/ usr/local/mysql/bin/mysqladmin-uroot-paminglinux.com password '123' # reset password

Mysql-uroot-paminglinux.com / / Log in to mysql

Use sock to log in locally to mysql-uroot-S/tmp/mysql.sock-paminglinux.com

/ / mysql5.7root has a default password.

Mysql statement

Grant all on discuz.* to'aming'@'localhost' identified by '123456 aminglinux. authorization

Show databases; / / View all databases

Create database tx1; / / create a database

Use tx1; / / use a database

Create table tx1 (`id` int (4), `name`char (40)); / / create a table

Insert into tx1 values (1)

Show tables; / / View the table

Desc tx1; / / View the fields of the table

Truncate table tx1; / / clear the table

Drop table tx1; / / Delete the table

Drop database tx1; / / Delete the database

Show create table tx1; / / View the construction data

Select user (); / / View the current user

Select database (); / / View current database

Select version; / / View database version

Show status; / / View mysql parameters for tuning

Which engines are supported by show engines; / /

Show variables like'% storage_engine%'; / / which engine is currently in use

Show create table table name; / / which engine is used for a table

Mysql operation

Vim / etc/my.cnf

Open slow query log

Add content in [mysqld]

Long_query_time = 1

Log_slow_queries = / data/mysql/slow.log

Root password reset

Add content in [mysqld]

Skip-grant / / indicates that no authorization is required to enter the database

/ etc/init.d/mysqld restart

Mysql / / No password is required to enter the database at this time

Mysql > use mysql

Mysql > update user setpassword=password ('aming') where user='root'

Mysql > exit

Modify / etc/my.cnf remove skip-grant and restart the service, and the password has been changed successfully.

Mysql remote login

First, it is authorized in the local database (CVM).

Mysql > grant all on *. * to'root'@'192.168.134.141' identified by '123456'

All all permissions * all libraries, * all tables, root users, 192.168.134.141 remote IP (client) 123456 remote login password

And then on 192.168.134.141 this machine executes

/ usr/local/mysql/bin/mysql-uroot-h292.168.134.137-P3306-p123456

Mysql > select user (); / / View the current user

Database backup and recovery

Mysqldump-uroot-predhat--default-character-set=gbk discuz > / data/discuz.sql / / backup Library

Mysql-uroot-predhat--default-character-set=gbk discuz

< /data/discuz.sql //恢复库 mysqldump -uroot -predhat--default-character-set=gbk discuz pre_forum_post >

/ data/post.sql / / back up the table

Mysql-uroot-predhat--default-character-set=gbk discuz < / data/post.sql / / restore table

Mysql installation and configuration steps to tell you here, for other related issues you want to know can continue to pay attention to our industry information. Our section will capture some industry news and professional knowledge to share with you every day.

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