Go MARIADB the root password after forgetting the workaround

Source: Internet
Author: User

Environment background: CentOS 7.2

I. Edit the/usr/lib/systemd/system/mariadb.service file and add it in the service segment
123456789101112 [service] type=simple user=mysql group=mysql user= MySQL group=mysql  execstartpre= Code class= "Bash plain" >/usr/libexec/mariadb-prepare-db-dir  %n # note: we set --basedir to prevent probes that  might trigger selinux alarms, # per bug  #547485 #在Server段中的ExecStart出添加如下 execstart= /usr/bin/mysqld_safe  --basedir= Code class= "Bash plain" >/usr  --skip-grant-tables --skip-networking

Ii. type Systemctl daemon-reload to make it effective immediately

1 [[email protected] ~]# systemctl daemon-reload
Third, restart the MARIADB service and use MySQL to enter
1234567891011 [[email protected] ~]# systemctl restart mariadb.service[[email protected] ~]# mysqlWelcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection idis 2Server version: 5.5.44-MariaDB MariaDB ServerCopyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.Type ‘help;‘or ‘\h‘for help. Type ‘\c‘to clearthe current input statement.MariaDB [(none)]>
Iv. changing the password of the root user

123456 < Code class= "Bash Plain" >mariadb [(none)]> update mysql.user set password=password ( ' Xiaoshui ' )  where user= ' root '  and host= ' localhost ' query ok, 0 rows affected  (0.00 sec) rows matched: 1  changed: 0  warnings: 0  mariadb [(none)]> flush privileges; query ok, 0 rows affected  (0.00 sec)
V. Exit and close the MARIADB service and remove the two lines just added in the/usr/lib/systemd/system/mariadb.service file
12 ExecStart=/usr/bin/mysqld_safe--basedir=/usr ExecStartPost=/usr/libexec/mariadb-wait-ready$MAINPID
Vi. start the MARIADB service and connect using the newly set password
1234567891011 [[email protected] ~]# mysql -u root -h localhost -pEnter password: Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection idis 4Server version: 5.5.44-MariaDB MariaDB ServerCopyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.Type ‘help;‘ or ‘\h‘forhelp. Type ‘\c‘to clearthe current input statement.MariaDB [(none)]>

Reference: http://dashui.blog.51cto.com/11254923/1877042

Go MARIADB the root password after forgetting the workaround

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.