Install Mysql in Linux (1)

Source: Internet
Author: User
Tags localhost mysql administrator password
How to install mysql's Binary source code package in Linux-Advanced User

After several days of research, I finally learned how to install the mysql Binary source code package in Linux, and finally solved ERROR 1045 (28000 ): access denied for user 'root' @ 'localhost, okay. Let's take a look at my installation steps!
1.download mysql-5.0.51a-linux-i686-glibc23.tar.gz for http://download.unix-center.net/... i686-glibc23.tar.gz
2. Put the downloaded file in your home directory and enter ls on the terminal, as shown below:
[Root @ localhost mysql] # ls
Desktop Documents Download Music mysql-5.0.51a-linux-i686-glibc23.tar.gz Pictures Public Templates Videos
3. decompress the package to the current directory with the tar-zxvf mysql-5.0.51a-linux-i686-glibc23.tar.gz Command, as shown below:
[Root @ localhost mysql] # tar-zxvf mysql-5.0.51a-linux-i686-glibc23.tar.gz
[Root @ localhost mysql] # ls
Desktop Download mysql-5.0.51a-linux-i686-glibc23 Pictures Templates
Documents Music mysql-5.0.51a-linux-i686-glibc23.tar.gz Public Videos
4. Because the source code is used, you need to copy the file to the installation directory/usr/local/to run it!
[Root @ localhost mysql] # cp-rf mysql-5.0.51a-linux-i686-glibc23/usr/local/
5. Check whether mysql has been installed in the system and find the rpm as follows:
[Root @ localhost mysql] # rpm-qa | grep mysql
If yes, delete them one by one. Run the rpm-e command to find the remaining files:
[Root @ localhost mysql] # cd/
[Root @ localhost/] # find/-name mysql
If rm-rf filename is found to be deleted.
[Root @ localhost/] # find/-name my. cnf
If the deletion is found, my. cnf is in/etc/my. cnf.
6. Link to mysql, as shown below:
[Root @ localhost/] # cd/home/mysql
[Root @ localhost mysql] # ln-s mysql-5.0.51a-linux-i686-glibc23/usr/local/mysql
7. initialize the mysql table and install the default mysql database as follows:
[Root @ localhost mysql] # cd/usr/local/mysql
[Root @ localhost mysql] # scripts/mysql_install_db -- user = mysql
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
Support-files/mysql. server to the right place for your system

Please remember to set a password for the MySQL root USER!
To do so, start the server, then issue the following commands:
./Bin/mysqladmin-u root password 'new-password'
./Bin/mysqladmin-u root-h localhost. localdomain password 'new-password'

Alternatively you can run:
./Bin/mysql_secure_installation

Which will also give you the option of removing the test
Databases and anonymous user created by default. This is
Stronugly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon:
Cd ..;./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
Cd mysql-test; perl mysql-test-run.pl

Please report any problems with the./bin/mysqlbug script!

The latest information about MySQL is available on the web
Http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
8. Modify the directory permission as follows:
[Root @ localhost mysql] # cd/usr/local
[Root @ localhost local] # chgrp-R mysql mysql-5.0.51a-linux-i686-glibc23.
[Root @ localhost local] # chgrp-R mysql
[Root @ localhost local] # chown-R mysql mysql-5.0.51a-linux-i686-glibc23/data
[Root @ localhost local] # chown-R mysql/data
[Root @ localhost local] # ln-s/usr/local/mysql/bin/*/usr/local/bin/
Ln: creating symbolic link '/usr/local/bin/CMakeLists.txt': File exists
Ln: creating symbolic link '/usr/local/bin/comp_err': File exists
Ln: creating symbolic link '/usr/local/bin/comp_ SQL .c': File exists
Ln: creating symbolic link '/usr/local/bin/make_sharedlib_distribution': File exists
Ln: creating symbolic link '/usr/local/bin/make_win_bin_dist': File exists
Ln: creating symbolic link '/usr/local/bin/make_win_src_distribution_old'
Article Source: http://www.diybl.com/course/7_da... 2008927/146278. html

Http://zrf8579.yourblog.org/logs/522139.html

Install MySQL. Suppose you have put all the necessary source code or packages under/tmp. If you download an RPM package, it is relatively simple; if you download a Binary Package (you do not have an rpm program or you want to customize it), it will be a little more troublesome. To install the RPM package, you must be the root user to use the rpm Installer. The installation process is as follows: $ cd/tmp $ su # rpm-Uvh MySQL * (install all MySQL-related packages) this will install all three MySQL packages you downloaded. If your system is RedHat Linux, we recommend that you use the RPM installation method, because all the work is done by the rpm program. The installation of source code is a little troublesome compared with the installation of RPM. However, you can customize the installation parameters in the installation script, instead of installing the default one in rpm mode. Install the Binary source code. If you download the Binary source code, its name is similar to: mysql-3.22.21-pc-linux-gnu-i686.tar.gz. You must be the root user and decompress the package to the/usr/local directory. The procedure is as follows: $ cd/usr/local $ su # tar-zxvf/tmp/mysql-3.22.21-pc-linux-gnu-i686.tar.gz after all files are decompressed, a directory named mysql-3.22.21-pc-linux-gnu-i686 will be created. We make a symbolic link for this directory and give it a more friendly name mysql (lest it be called mysql-3.22.21-pc-linux-gnu-i686 so long): # ln-s mysql-3.22.21-pc-linux-gnu-i686 mysql if there is a new version of MySQL later, you can just extract the source code to a new path, and then just create a symbolic link. This is very convenient and data is more secure. Create a MySQL user. Now we will create a user account that can run the MySQL daemon, and all MySQL files are owned by this account. Use the Linuxconf or useradd command to add an account named mysql. Before adding the account, make sure that no one has registered the account, you must temporarily disable the login function (however, this step is generally skipped when no one else logs in to debug the machine) prepare for MySQL. First, let's change the ownership of the MySQL directory and file to the mysql user and root group: # cd/usr/local # chown-R mysql: root mysql-3.22.21-pc-linux-gnu-i686 mysql then runs a small script program to build the initialized MySQL database. Please complete this task as a mysql user, which is the only opportunity for us to directly use this account. # Su mysql $ cd mysql $ scripts/mysql_install_db $ exit if no error information is displayed, you can. Automatically run MySQL in the MySQL Binary Package. There is a STARTUP script program named myslq. server. Copy it to/etc/rc. d/init. d directory: # cd/etc/rc. d/init. d # cp/usr/local/mysql/support-files/mysql. server mysql then changes its attribute to "x" (executable, executable) # chmod + x mysql. Finally, run chkconfig to add MySQL to the startup Service Group of your system. #/Sbin/chkconfig -- del mysql #/sbin/chkconfig -- add mysql to test MySQL. A simple database example test is provided in MySQL, in addition, its internal database keeps monitoring of permissions and accounts, so first run mysql to see if it can work. Start MySQL first: #/etc/rc. d/init. d/mysql start if everything is normal, you will see the following information: Starting mysqld daemon with databases from/var/lib/mysql if you install the RPM package, most programs are installed in/usr/local/mysql/bin. Run the client program in this directory: # mysql, and the following information is displayed on the screen: Welcome to the MySQL monitor. commands end with; or/g. your MySQL connection id is 2 to server version: 3.22.21 Type 'help' for help. mysql> then, use the show databases command to list the installed databases: mysql> show databases; you can see: + ---------- + | Database | + ---------- + | mysql | test | + ---------- + 2 rows in set (0.00 sec) if everything works properly, it means MySQL can work completely! Congratulations! If you want to exit the program, enter exit mysql> exit; Bye to change the administrator password. After everything is normal, the first thing to do is to change the administrator password. You can run mysqladmin (note that this command is not necessarily in your path, so it is best to directly execute it in the directory of this command ): # mysqladmin-u root password newpassword this command changes the password of the root user into newpassword. Of course, you can change the password to another one, because MySQL is a multi-user, multi-thread SQL database server. It can be used for relational databases on various popular operating system platforms. It has a distributed database management system with a client/server architecture. MySQL is fully applicable to networks. Databases built with MySQL can be accessed anywhere on the Internet. MySQL can use the SQL language. SQL (Structured Query Language) is the world's most popular and standardized database language. MySQL is implemented in a Client/Server structure. It consists of a server daemon mysqld and many different client programs and libraries. SQL is a standardized language that makes it easier to store and update information. MySQL is designed to be fast, robust, and easy to use. I. resources required for MySQL installation: In XteamLinux 4.0, MySQ is installed by default.


 

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.