Install the MySQL Binary source code package in Linux

Source: Internet
Author: User
Tags localhost mysql

After several years 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/mysql/mysql-5.0.51a-linux-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': File exists
Ln: creating symbolic link '/usr/local/bin/msql2mysql': File exists
Ln: creating symbolic link '/usr/local/bin/myisamchk': File exists
Ln: creating symbolic link '/usr/local/bin/myisam_ftdump': File exists
Ln: creating symbolic link '/usr/local/bin/myisamlog': File exists
Ln: creating symbolic link '/usr/local/bin/myisampack': File exists
Ln: creating symbolic link '/usr/local/bin/my_print_defaults': File exists
Ln: creating symbolic link '/usr/local/bin/mysqlaccess': File exists
Ln: creating symbolic link '/usr/local/bin/mysqlaccess. conf': File exists
Ln: creating symbolic link '/usr/local/bin/mysqladmin': File exists
Ln: creating symbolic link '/usr/local/bin/mysqlbinlog': File exists
Ln: creating symbolic link '/usr/local/bin/mysqlbug': File exists
Ln: creating symbolic link '/usr/local/bin/mysqlcheck': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_client_test': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_config': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_convert_table_format': File exists
Ln: creating symbolic link '/usr/local/bin/mysqld': File exists
Ln: creating symbolic link '/usr/local/bin/mysqld-debug': File exists
Ln: creating symbolic link '/usr/local/bin/mysqld_multi': File exists
Ln: creating symbolic link '/usr/local/bin/mysqld_safe': File exists
Ln: creating symbolic link '/usr/local/bin/mysqldump': File exists
Ln: creating symbolic link '/usr/local/bin/mysqldumpslow': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_explain_log': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_find_rows': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_fix_extensions': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_fix_privilege_tables': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_fix_privilege_tables_ SQL .c': File exists
Ln: creating symbolic link '/usr/local/bin/mysqlhotcopy': File exists
Ln: creating symbolic link '/usr/local/bin/mysqlimport': File exists
Ln: creating symbolic link '/usr/local/bin/mysqlmanager': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_secure_installation': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_setpermission': File exists
Ln: creating symbolic link '/usr/local/bin/mysqlshow': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_tableinfo': File exists
Ln: creating symbolic link '/usr/local/bin/mysqltest': File exists
Ln: creating symbolic link '/usr/local/bin/mysqltestmanager': File exists
Ln: creating symbolic link '/usr/local/bin/mysqltestmanagerc': File exists
Ln: creating symbolic link '/usr/local/bin/mysqltestmanager-pwgen': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_tzinfo_to_ SQL': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_upgrade': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_upgrade_shell': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_waitpid': File exists
Ln: creating symbolic link '/usr/local/bin/mysql_zap': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_config': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_cpcd': File exists
Ln: creating symbolic link '/usr/local/bin/ndbd': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_delete_all': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_desc': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_drop_index': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_drop_table': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_error_reporter': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_mgm': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_mgmd': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_restore': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_select_all': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_select_count': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_show_tables': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_size.pl': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_test_platform': File exists
Ln: creating symbolic link '/usr/local/bin/ndb_waiter': File exists
Ln: creating symbolic link '/usr/local/bin/perror': File exists
Ln: creating symbolic link '/usr/local/bin/replace': File exists
Ln: creating symbolic link '/usr/local/bin/resolveip': File exists
Ln: creating symbolic link '/usr/local/bin/resolve_stack_dump': File exists
Ln: creating symbolic link '/usr/local/bin/safe_mysqld': File exists
9. Start mysql_safe as follows:
[Root @ localhost local] # bin/mysqld_safe -- user = mysql -- socket =/tmp/mysql. sock -- port = 3306 &
[1] 26860
[Root @ localhost local] # nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from/usr/local/mysql/data
Check whether port 3308 is listening:
Netstat-anp | grep LISTEN
10. Add to System Auto-start as follows:
[Root @ localhost local] # cp mysql/support-files/mysql. server/etc/rc. d/init. d/mysqld
[Root @ localhost local] # chkconfig -- add mysqld
11. Start the mysql service process as follows:
[Root @ localhost local] #/etc/init. d/mysqld start
Starting MySQL [OK]
12. Specify the password "python" for the root user and localhost as follows:
[Root @ localhost local] # bin/mysqladmin -- socket =/tmp/mysql. sock -- port = 3306-u root-h localhost password 'python'
13. log on to the root account and authorize the root account! As follows:
[Root @ localhost local] # bin/mysql -- port = 3306-u root-p-S/tmp/mysql. sock
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 2
Server version: 5.0.51a MySQL Community Server (GPL)

Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.

Mysql> grant all privileges on *. * to 'root' @ 'localhost' identified by 'python ';
Query OK, 0 rows affected (0.54 sec) # [grant all permissions to the root user connected using localhost]

Mysql> flush privileges;
Query OK, 0 rows affected (0.26 sec) # [refresh the user permission list and update permissions]
Mysql> quit
Bye
14. Create a user as follows:
// Log on to MYSQL
[Root @ localhost local] # bin/mysql -- port = 3306-u root-p-S/tmp/mysql. sock
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 3
Server version: 5.0.51a MySQL Community Server (GPL)

Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.
// Use the mysql database
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-

Database changed
// Create a user
Mysql> insert into mysql. user (Host, User, Password) values ("localhost", "django", password ("django "));
Query OK, 1 row affected, 3 warnings (0.60 sec)
// Refresh the system permission list
Mysql> flush privileges;
Query OK, 0 rows affected (0.08 sec)
In this way, a user named: django with the password: django is created.
// Then log on
Mysql> exit;
Bye
[Root @ localhost local] # bin/mysql -- port = 3306-u django-p-S/tmp/mysql. sock
Enter password: // Enter the authorization code
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 4
Server version: 5.0.51a MySQL Community Server (GPL)

Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.

Mysql> // login successful!
Mysql> exit;
Bye
15. Authorize the new user account as follows:
// Log on to MYSQL (with ROOT permission ). I log on as ROOT.
[Root @ localhost local] # bin/mysql -- port = 3306-u root-p-S/tmp/mysql. sock
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 2
Server version: 5.0.51a MySQL Community Server (GPL)

Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.

Mysql>
// Create a database for the user (django_demo)
Mysql> create database django_demo;
Query OK, 1 row affected (0.41 sec)
// Authorize the django user to have all permissions for the django_demo database.
Mysql> grant all privileges on django_demo. * to 'django '@ 'localhost' identified by 'django ';
Query OK, 0 rows affected (0.13 sec)
// Refresh the system permission list
Mysql> flush privileges;
Query OK, 0 rows affected (0.09 sec)

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.