-->

DEVOPSZONES

  • Recent blogs

    How to Set root password in Mysql or Maria DB

    How to Set root password in Mysql or Maria DB.

    1. Run this command to start MySql in Safe Mode. 
    [root@exampledb ~]# mysqld_safe --skip-grant-tables &
    [1] 17827
    [root@exampledb ~]# 161205 15:26:12 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
    161205 15:26:12 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

    [root@exampledb ~]#

    2.  Connect to MySQL.
    [root@exampledb ~]# mysql
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 1
    Server version: 5.5.44-MariaDB MariaDB Server

    Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


    3. Use MySQL Database.
    MariaDB [(none)]> use mysql;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed

    4. Change root Password
    MariaDB [mysql]> UPDATE user SET password=PASSWORD("password") WHERE User='root';
    Query OK, 3 rows affected (0.00 sec)
    Rows matched: 3  Changed: 3  Warnings: 0

    5. Flush Privileges and Quit.
    MariaDB [mysql]> FLUSH PRIVILEGES;
    ERROR 1146 (42S02): Table 'mysql.servers' doesn't exist
    MariaDB [mysql]> quit;
    Bye
    [root@exampledb ~]#

    6. Login to the databases.
    [root@exampledb ~]# mysql -u root -p
    Enter password:
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 3
    Server version: 5.5.44-MariaDB MariaDB Server

    Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    MariaDB [(none)]>

    No comments