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

CentOS6.7 Mysql5.6.35 version source code compilation + Mysql database forget how to change root password

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Source code compilation MySQL

[root@CentOS61 ~] # yum install cmake nucrses-devel-y / / install the development package for compiling environment and terminal operation

……

Installed:

Cmake.x86_64 0VOR 2.8.12.2-4.el6

Dependency Installed:

Libarchive.x86_64 0VOR 2.8.3-7.el6_8

Complete!

Download the software package

[root@CentOS61 ~] # wget http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.6/mysql-5.6.35.tar.gz

.

32167628 24.0K/s in 2.2s

2017-04-12 22:23:19 (24.0 KB/s)-"mysql-5.6.35.tar.gz" saved [32167628]

Note: if the command is slow to download, you can download it using windows and then upload it to linux.

Decompression

[root@CentOS61 ~] # tar-xf mysql-5.6.35.tar.gz-C / usr/local/src/-C specify the decompression directory

[root@CentOS61 ~] # ls / usr/local/src/

Mysql-5.6.35

Check whether the mysql user exists

[root@CentOS61 ~] # grep mysql / etc/passwd

Create a user

[root@CentOS61] # useradd-u 8001-s / sbin/nologin mysql

Create a database directory

[root@CentOS61 ~] # mkdir / data

Enter the directory to compile and install

[root@CentOS61 ~] # cd / usr/local/src/mysql-5.6.35/

[root@CentOS61 mysql-5.6.35] # cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_UNIX_ADDR=/tmp/mysql.sock-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS=all-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1-DWITH_READLINE=1-DENABLED_LOCAL_INFILE=1-DMYSQL_DATADIR=/data-DMYSQL_USER=mysql

Start compilation and installation

[root@CentOS61 mysql-5.6.35] # make-j 4 & & make install

Use $at the end? Check to see if it is successful

[root@CentOS61 mysql-5.6.35] # echo $?

0

User authorization

[root@CentOS61 mysql-5.6.35] # chown-R mysql:mysql / usr/local/mysql

[root@CentOS61 mysql-5.6.35] # chown-R mysql:mysql / data

[root@CentOS61 mysql-5.6.35] # chmod 1777 / tmp/

Create a profile

Overwrite existing configuration files

[root@CentOS61 mysql-5.6.35] # cp / usr/local/mysql/support-files/my-default.cnf / etc/my.cnf

Cp: overwrite `/ etc/my.cnf'? Y

Set environment variabl

[root@CentOS61 mysql-5.6.35] # echo 'export PATH=/usr/local/mysql/bin:$PATH' > > / etc/profile

[root@CentOS61 mysql-5.6.35] # source! $/ / effective file

Source / etc/profile

Create a service startup script

[root@CentOS61 mysql-5.6.35] # cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqld / / copy startup script and rename it to mysqld

[root@CentOS61 mysql-5.6.35] # chmod + x! $

Chmod + x / etc/init.d/mysqld / / Grant script execution permission

[root@CentOS61 ~] # vim / etc/init.d/mysqld

Modify

46 basedir=

47 datadir=

For

46 basedir=/usr/local/mysql

47 datadir=/data

Set Boot self-boot

[root@CentOS61 ~] # chkconfig mysqld on / / set boot self-startup

Initialize the database

[root@CentOS61 ~] # chmod + x / usr/local/mysql/scripts/mysql_install_db / / add execution permissions to the directory

[root@CentOS61 ~] # / usr/local/mysql/scripts/mysql_install_db-- defaults-file=/etc/my.cnf-- basedir=/usr/local/mysql/-- datadir=/data/-- user=mysql / / specify configuration file, directory, user (it will take some time)

Initialize the security configuration

[root@CentOS61 ~] # service mysqld start / / start the service

Starting MySQL.Logging to'/ data/CentOS61.err'.

. SUCCESS!

Note: it will take a few minutes. It may be the version of the database.

[root@CentOS61 ~] # service mysqld status / / View service status

SUCCESS! MySQL running (16856)

[root@CentOS61 ~] # mysql_secure_installation

……

Enter current password for root (enter for none): / / A password is required. Enter directly without a password.

……

Set root password? [Ymen] Y / / prompt to set the root password

New password: / / enter the password 123456 to be set (shown in ciphertext)

Re-enter new password: / / repeat confirmation of password

……

Remove anonymous users? [YPop] y / / whether to delete anonymous users (anonymous users can log in to the server and need to be deleted)

.

Disallow root login remotely? [Yopin] Y / / prohibit root users from logging in remotely

……

Remove test database and access to it? [YBO] Y / / Delete the test database (once the database is created, the test database is useless)

……

Reload privilege tables now? [YPo] Y / / refresh the list of databases

Log into the database

[root@CentOS61] # mysql-u root-p123456 / / Log in to the database

Mysql > show engines; / / View default engine

+-- +

| | Engine | Support | Comment | Transactions | XA | Savepoints | |

+-- +

| | FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL | |

| | MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO | |

| | MyISAM | YES | MyISAM storage engine | NO | NO | NO | |

| | BLACKHOLE | YES | / dev/null storage engine (anything you write to it disappears) | NO | NO | NO |

| | CSV | YES | CSV storage engine | NO | NO | NO | |

| | MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |

| | ARCHIVE | YES | Archive storage engine | NO | NO | NO | |

| | InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |

| | PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO | |

+-- +

9 rows in set (0.00 sec)

Install MySQL Complete

Mysql database forgot how to change root password

Environment: CentOS6.7 Mysql5.6.35 version of Mysql database forgot how to change root password

Log in to the Mysql database and forget your password

[root@CentOS61 ~] # mysql-V / / View mysql version

Mysql Ver 14.14 Distrib 5.6.35, for Linux (x86 / 64) using EditLine wrapper

[root@CentOS61 ~] # mysql-uroot-p / / Log in to the database

Enter password: / / forget your password

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Change root password 1, stop mysql service

[root@CentOS61 ~] # service mysqld stop

Shutting down MySQL.. SUCCESS!

2. Enter skip-grant-tables mode

[root@CentOS61] # mysqld_safe-- skip-grant-tables

170413 01:51:11 mysqld_safe Logging to'/ data/CentOS61.err'.

170413 01:51:11 mysqld_safe Starting mysqld daemon with databases from / data

Ctrl+z terminates after resetting the root password

[1] + Stopped mysqld_safe-- skip-grant-tables

Open a new window to log in to the database, you can skip password authentication

[root@CentOS61 ~] # mysql / / directly enter the database

Mysql > use mysql / / enter mysql database

Mysql > update user set password=password ("1234567") where user= "root"; / / modify root password

Query OK, 3 rows affected (0.00 sec)

Rows matched: 3 Changed: 3 Warnings: 0

Mysql > flush privileges; / / refresh permissions

Query OK, 0 rows affected (0.01 sec)

Mysql > exit / / exit the database

[root@CentOS61 ~] # pkill mysql / / stop mysql database

[root@CentOS61 ~] # service mysqld start

Starting MySQL.. SUCCESS!

[root@CentOS61 ~] # mysql-uroot-p1234567 / / log in to the database with a new password

Root password modified successfully

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