Get the App
SLTechnology News&Howtos  ›  Database  › 

Binary installation of mysql database installation

Shulou Source: shulou.com Published: 2022-06-01 19:12:53 09月15日 Update

# install mysql in binary, decompress and initialize the database directly

1. Create users and groups

[root@Lnmp tools] # useradd mysql-s / sbin/nologin/-M

two。 Extract the installation package

[root@Lnmp tools] # tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz

[root@Lnmp tools] # mv mysql-5.5.32-linux2.6-x86_64 mysql

[root@Lnmp tools] # mv mysql / application/

# stand-alone installation of the database ends here.

[root@Lnmp tools] # mkdir-p / application/mysql/data/

[root@Lnmp tools] # chown-R mysql.mysql / application/mysql/data

3. Initialize the database

[root@Lnmp tools] # cd / application/mysql/

[root@Lnmp mysql] # / scripts/mysql_install_db-- user=mysql-- basedir=/application/mysql/-- datadir=/application/mysql/data/

WARNING: The host 'Lnmp' could not be looked up with resolveip.

This probably means that your libc libraries are not 100% compatible

With this binary MySQL version. The MySQL daemon, mysqld, should work

Normally with the exception that host name resolving will not work.

This means that you should use IP addresses instead of hostnames

When specifying MySQL privileges!

Installing MySQL system tables...

OK

Filling help tables...

OK

[root@Lnmp mysql] #\ cp support-files/mysql.server / etc/init.d/mysqld

[root@Lnmp mysql] # cp support-files/my-small.cnf / etc/my.cnf # specify configuration file

# if it is not specified, it appears at startup:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/ var/lib/mysql/mysql.sock/ (2)

4. Start Mysql:

[root@Lnmp mysql] # / etc/init.d/mysqld start

/ etc/init.d/mysqld: line 276: cd: / usr/local/mysql: No such file or directory

Starting MySQL ERROR! Couldn't find MySQL server (/ usr/local/mysql/bin/mysqld_safe)

If not, modify the following:

[root@Lnmp mysql] # vi / etc/init.d/mysqld + 46

Basedir=/application/mysql

Datadir=/application/mysql/data

[root@Lnmp mysql] # / etc/init.d/mysqld start

Starting MySQL.. SUCCESS!

# Login

# mysql

The following error occurred:

#-bash:mysql:command not found

The path corresponding to mysql is not under the path directory.

Use the full path to enter mysql:

/ application/mysql/bin/mysql

Or add at the end of the document:

Vi / etc/profile

PATH= "/ application/mysql/bin/:$PATH"

#. / etc/profile # to make it effective

Mysql >

# set password, do not set password under mysql >, set password after #

/ application/mysql/bin/mysqladmin-u root password 'passwd123'

# sign in again

Mysql-u root-p

Passwd123

5. Data optimization:

Select version (); # View the database version

Select user (); # View current users

Mysql > show databases; # View the database

+-+

| | Database |

+-+

| | information_schema |

| | mysql |

| | performance_schema |

| | test |

+-+

Mysql > drop database test; # security settings, delete useless databases

# finally optimized as follows:

Mysql > show databases

+-+

| | Database |

+-+

| | information_schema |

| | mysql |

| | performance_schema |

+-+

Mysql > select user,host from mysql.user; # query the users in the table

+-+ +

| | user | host |

+-+ +

| | root | 127.0.0.1 | |

| | root |:: 1 |

| | Lnmp |

| | root | Lnmp |

| | localhost |

| | root | localhost |

+-+ +

Mysql > delete from mysql.user where (host= "Lnmp")

Mysql > delete from mysql.user where (host= ":: 1")

Mysql > drop user "" @ localhost

# finally optimized as follows:

Mysql > select user,host from mysql.user

+-+ +

| | user | host |

+-+ +

| | root | 127.0.0.1 | |

| | root | localhost |

+-+ +

Finally:

Flush privileges

Tags: Data database password user file path login binary security success rule useful query table version directory error timeout query stand-alone configuration Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei OPPO Reno Shulou Tech Info Redmi Shulou Information