您的位置:首页 > 运维架构 > Linux

How to Install MySQL 5.1 Database on A Linux Server

2011-09-18 18:53 796 查看
How to
Install MySQL 5.1 on A Linux Server


Nearly all of the Linux distro comes with MySQL. If you need use MySQL, my suggestion is always that you download the most recent edition of MySQL and set up it yourself. Later you'll be able to upgrade it to your most up-to-date edition when it gets available.
In this write-up, I will make clear the way to set up the newest cost-free group version of MySQL on Linux platform.

1. Download the latest secure relase of MySQL

Down load mySQL from mysql.com . Make sure you down load the neighborhood version of MySQL for the acceptable Linux platform. I downloaded the ???Red Hat Enterprise Linux five RPM (x86)??à. Ensure to down load MySQL Server, Client and ???Headers and libraries??à
through the download web page.

MySQL-client-community-5.1.25-0.rhel5.i386.rpm

MySQL-server-community-5.1.25-0.rhel5.i386.rpm

MySQL-devel-community-5.one.25-0.rhel5.i386.rpm

2. Eliminate the existing default MySQL that arrived together with the Linux distro

Usually do not complete this on an method wherever the MySQL database is acquiring utilized by some applicationone.0.1

mysqlclient10-3.23.58-4.RHEL4.one

[local-host]# rpm -e mysql --nodeps

warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave

[local-host]# rpm -e mysqlclient10

3. Install the downloaded MySQL deal

Set up the MySQL Server and Client deals as demonstrated beneath.

[local-host]# rpm -ivh MySQL-server-community-5.1.25-0.rhel5.i386.rpm MySQL-client-community-5.1.25-0.rhel5.i386.rpm

Planning... ########################################### [100%]

one:MySQL-client-community ########################################### [ 50%]

two:MySQL-server-community ########################################### [100%]

This will also screen the following output and start the MySQL daemon instantly.

Remember to Don't forget TO SET A PASSWORD For your MySQL root User !

To complete so, start the server, then concern the following commands:

/usr/bin/mysqladmin -u root password 'new-password'

/usr/bin/mysqladmin -u root -h medica2 password 'new-password'

Alternatively it is possible to operate:

/usr/bin/mysql_secure_installation

which is able to also provide you with the choice of taking away the check

databases and anonymous person designed by default. This can be

firmly recommended for production servers.

See the handbook for far more guidelines.

Please report any troubles with the /usr/bin/mysqlbug script!

The latest information about MySQL is available at http://www.mysql.com/
Assistance MySQL by purchasing support/licenses from http://shop.mysql.com/
Commencing MySQL.[ Okay ]

Providing mysqld two seconds to get started on

Set up the ???Header and Libraries??à which might be element of the MySQL-devel deals.

[local-host]# rpm -ivh MySQL-devel-community-5.one.25-0.rhel5.i386.rpm

Planning... ########################################### [100%]

1:MySQL-devel-community ########################################### [100%]

Note: When I was compiling PHP with MySQL selection from source within the Linux technique, it failed together with the adhering to error. Putting in the MySQL-devel-community bundle fixed this problem in setting up PHP from supply.

configure: error: Cannot find MySQL header information underneath certainly.

Be aware the MySQL consumer library just isn't bundled any more!

4. Complete post-install protection activities on MySQL.

At a bare bare minimum you must set a password for the root person as shown below:

[local-user]# /usr/bin/mysqladmin -u root password 'My2Secure$Password'

The best option is usually to run the mysql_secure_installation script that will just take care of every one of the standard security associated items about the MySQL as proven under. On the high level this does the subsequent things:

Change the root password

Take away the anonymous consumer

Disallow root login from remote machines

Get rid of the default sample test database

[local-host]# /usr/bin/mysql_secure_installation

Be aware: Operating ALL Areas OF THIS SCRIPT IS Encouraged FOR ALL MySQL

SERVERS IN Production USE! Remember to Read through Each and every Stage Meticulously!

To be able to log into MySQL to safe it, we'll need to have the current

password for that root person. If you have just installed MySQL, and

you haven't set the root password yet, the password will be blank,

which means you ought to just press enter right here.

Enter existing password for root (enter for none):

Ok, efficiently used password, moving on...

Setting the root password guarantees that no one can log in to the MySQL

root consumer without the appropriate authorisation.

You have already got a root password set, therefore you can securely answer 'n'.

Transform the root password? [Y/n] Y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MySQL set up has an anonymous user, making it possible for anyone

to log into MySQL without having to possess a user account designed for

them. This really is supposed only for testing, and also to make the set up

go a little smoother. You need to take away them prior to moving into a

creation setting.

Take away anonymous customers? [Y/n] Y

... Success!

Normally, root need to only be permitted to hook up from 'localhost'. This

ensures that someone cannot guess on the root password from your network.

Disallow root login remotely? [Y/n] Y

... Results!

By default, MySQL comes with a database named 'test' that any person can

accessibility. That is also supposed only for testing, and ought to be taken out

ahead of relocating into a manufacturing surroundings.

Remove check database and access to it? [Y/n] Y

- Dropping check database...

... Good results!

- Removing privileges on test database...

... Good results!

Reloading the privilege tables will make sure that all changes created so far

will just take impact right away.

Reload privilege tables now? [Y/n] Y

... Achievement!

Cleaning up...

All accomplished! If you've completed each of the above steps, your MySQL

set up should now be safe.

Thanks for making use of MySQL!

5. Confirm the MySQL set up:

You can check out the MySQL installed model by carrying out mysql -V as proven beneath:

[local-host]# mysql -V

mysql Ver 14.14 Distrib five.1.25-rc, for redhat-linux-gnu (i686) utilizing readline 5.one

Hook up towards the MySQL database making use of the root user and ensure the link is successfull.

[local-host]# mysql -u root -p

Enter password:

Welcome to the MySQL check. Instructions end with ; or \g.

Your MySQL connection id is 13

Server version: 5.one.25-rc-community MySQL Local community Server (GPL)

Type 'help;' or '\h' for support. Sort '\c' to clear the buffer.

mysql>

Follows the methods beneath to stop and start MySQL

[local-host]# services mysql standing

MySQL working (12588) [ Ok ]

[local-host]# support mysql stop

Shutting down MySQL. [ Ok ]

[local-host]# support mysql begin

Beginning MySQL. [ Ok ]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息