Installing MySQL on Fedora 17/18
The following are the steps to install a MySQL in Fedora
Step1: Open terminal and change to root user
[ranga@ranga ~]$ su
Password:
[root@ranga ranga]#
Step2: Install Remi repository by using following command
[root@ranga ranga]# rpm -Uvh http://rpms.famillecollet.com/remi-release-17.rpm
-------------------------------------------------------------------
[root@ranga ranga]#
Step3: List out the all available versions
[root@ranga ranga]# yum --enablerepo=remi list mysql mysql-server
-------------------------------------------------------------------
Installed Packages
-------------------------------------------------------------------
mysql.x86_64 5.5.33-1.fc17.remi remi
mysql-server.x86_64 5.5.33-1.fc17.remi remi
[root@ranga ranga]#
Here available version is 5.5.33
Step4: Install or update available mysql version
[root@ranga ranga]# yum --enablerepo=remi install mysql mysql-server
--------------------------------------------------------
Installed:
mysql-server.x86_64 0:5.5.33-1.fc17.remi
--------------------------------------------------------
Updated:
mysql.x86_64 0:5.5.33-1.fc17.remi
Dependency Updated:
mysql-devel.x86_64 0:5.5.33-1.fc17.remi mysql-libs.x86_64 0:5.5.33-1.fc17.remi
Complete!
Step5: Start the MySQL server and autostart MySQL on boot
[root@ranga ranga]# systemctl start mysqld.service
[root@ranga ranga]# systemctl enable mysqld.service
ln -s '/usr/lib/systemd/system/mysqld.service' '/etc/systemd/system/multi-user.target.wants/mysqld.service'
Step6: MySQL Secure Installation
- Set (Change) root password(Mandatory)
- Remove anonymous users(Optional)
- Disallow root login remotely(Optional)
- Remove test database and access to it(Optional)
- Reload privilege tables(Optional)
[root@ranga ranga]# /usr/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] n
... skipping.
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
... skipping.
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] n
... skipping.
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Step7: Connect to MySQL database
[root@ranga ranga]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.5.33 MySQL Community Server (GPL) by Remi
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
List out the all databases:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql>
Creating the Database
mysql> CREATE DATABASE ranga;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| ranga |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql>
Creating the User and Droping the User
mysql> CREATE USER 'ranga' IDENTIFIED BY 'ranga';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL ON ranga.* TO 'ranga';
Query OK, 0 rows affected (0.01 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> drop user 'ranga';
Query OK, 0 rows affected (0.00 sec)
List out the all users, hosts, and passwords
mysql> select user, host, password from mysql.user;
+-------+-----------+-------------------------------------------+
| user | host | password |
+-------+-----------+-------------------------------------------+
| root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | ranga | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | 127.0.0.1 | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | ::1 | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| | localhost | |
| | ranga | |
| ranga | % | *446F5A1568CCBD4237563DD8AF67580D8CF5AAA9 |
+-------+-----------+-------------------------------------------+
7 rows in set (0.00 sec)
Set the User password
mysql> set password for root@'127.0.0.1'= password('password');
Query OK, 0 rows affected (0.00 sec)
Delete the User by username
mysql> delete from mysql.user where user='ranga';
Query OK, 1 row affected (0.00 sec)
mysql> select user, host, password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | ranga | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | 127.0.0.1 | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| root | ::1 | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| | localhost | |
| | ranga | |
+------+-----------+-------------------------------------------+
6 rows in set (0.00 sec)
Deleting the anonymous users
mysql> delete from mysql.user where user='';
Query OK, 2 rows affected (0.00 sec)
mysql> select user, host, password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | ranga | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | 127.0.0.1 | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
| root | ::1 | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+------+-----------+-------------------------------------------+
4 rows in set (0.00 sec)
mysql>
Quit from MySQL
mysql> exit
Bye
Changing MySQL root user password using MySQL sql command
1) Login to mysql server, type the following command at shell prompt:
$ mysql -u root -p
2) Use mysql database (type command at mysql> prompt):
mysql> 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
3) Change password for user 'ranga'
mysql> update user set password=PASSWORD("reddy") where User='ranga';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
4) Finally, reload the privileges:
mysql> flush privileges;
mysql> quit
MySQL Root Password Recovery
Step # 1: Stop the MySQL server process.
[root@ranga ranga]# /etc/init.d/mysql stop
Stopping MySQL database server: mysqld.
Step # 2: Start the MySQL (mysqld) server/daemon process with the --skip-grant-tables option so that it will not prompt for password.
[root@ranga ranga]# mysqld_safe --skip-grant-tables &
[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started
Step # 3: Connect to mysql server as the root user.
[root@ranga ranga]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Step # 4: Setup new mysql root account password i.e. reset mysql password.
mysql> use mysql;
mysql> update user set password=PASSWORD("root") where User='root';
mysql> flush privileges;
mysql> quit
Step # 5: Stop the Server.
[root@ranga ranga]#
/etc/init.d/mysql stop
Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended
Done mysqld_safe --skip-grant-tables
Step # 6: Start the Server and test it[root@ranga ranga]#
/etc/init.d/mysql start
[root@ranga ranga]#
mysql -u root -p
UnInstall the MySQL:
Step1:
[root@ranga ~]# rpm -qa | grep mysqlmysql-server-5.5.33-1.fc17.remi.x86_64
mysql-libs-5.5.33-1.fc17.remi.x86_64
mysql-devel-5.5.33-1.fc17.remi.x86_64
mysql-5.5.33-1.fc17.remi.x86_64
Step2:
Remove the all packages that come out of the query above.
Note:
You can tell RPM to ignore dependencies and just rip stuff out with the --nodeps flag.
[root@ranga ~]# rpm -e mysql-5.5.33-1.fc17.remi.x86_64 --nodeps
[root@ranga ~]# rpm -qa | grep mysql
mysql-server-5.5.33-1.fc17.remi.x86_64
mysql-libs-5.5.33-1.fc17.remi.x86_64
mysql-devel-5.5.33-1.fc17.remi.x86_64
[root@ranga ~]# rpm -e mysql-server-5.5.33-1.fc17.remi.x86_64 --nodeps
warning: /var/log/mysqld.log saved as /var/log/mysqld.log.rpmsave
[root@ranga ~]# rpm -e mysql-libs-5.5.33-1.fc17.remi.x86_64 --nodeps
[root@ranga ~]# rpm -e mysql-devel-5.5.33-1.fc17.remi.x86_64 --nodeps
[root@ranga ~]# rpm -qa | grep mysql
[root@ranga ~]#
In your system MySQL is successfully Uninstalled........
Another Trick to un install is
rpm -qa|grep <thing you want to uninstall> | xargs rpm -e
rpm -qa|grep mysql | xargs rpm -e
Simplest way of un install is System tools --> Add/Remove Application then looks for SQL and check MySQL to remove from the system.
Thanks for Reading this article.................