Fedora 10 上 Mysql-5.5.24 安装详解,彻底解决 Can't connect to local MySQL server through socket
2012-05-30 00:44
393 查看
Ubuntu上 安装 mysql 过程很简单(参考博客), 但在Fedora 上就很不好处理,主要是“安装完”后Mysql用不了。出现"ERROR
2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)" 的错误
以下是本人的安装过程,可能过于详细
当前系统已经安装,但是是以rpm安装的,所以
/lib /usr/local/lib 没有相关的库,
/include /usr/local/include也没有相关的头文件
无法进行调用 mysql的api,故源码安装。
删掉系统以前的mysql文件:
[root@localhost kamailio-3.2.3]# rpm -e mysql
[root@localhost kamailio-3.2.3]# ls -l /usr/bin/mysql*
[root@localhost kamailio-3.2.3]# ls /usr/bin/mysql* | xargs rm -f
地址:http://www.mysql.com/downloads/mysql/#downloads选择的platform为source
code,我安装时的最新版本是mysql-5.5.24.tar.gz(需要注册, 这里可以免注册下载);
2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)" 的错误
以下是本人的安装过程,可能过于详细
[root@localhost local]# rpm -qa mysql mysql-5.0.88-1.fc10.i386 [root@localhost local]#
当前系统已经安装,但是是以rpm安装的,所以
/lib /usr/local/lib 没有相关的库,
/include /usr/local/include也没有相关的头文件
无法进行调用 mysql的api,故源码安装。
删掉系统以前的mysql文件:
[root@localhost kamailio-3.2.3]# rpm -e mysql
[root@localhost kamailio-3.2.3]# ls -l /usr/bin/mysql*
-rwxr-xr-x 1 root root 287844 2009-11-25 01:59 /usr/bin/mysql -rwxr-xr-x 1 root root 110776 2009-11-25 01:59 /usr/bin/mysqlaccess -rwxr-xr-x 1 root root 34676 2009-11-25 01:59 /usr/bin/mysqladmin -rwxr-xr-x 1 root root 113816 2009-11-25 01:59 /usr/bin/mysqlbinlog -rwxr-xr-x 1 root root 5428 2009-11-25 01:59 /usr/bin/mysqlbug -rwxr-xr-x 1 root root 26840 2009-11-25 01:59 /usr/bin/mysqlcheck -rwxr-xr-x 1 root root 5432 2009-11-25 01:59 /usr/bin/mysql_config -rwxr-xr-x 1 root root 3670 2009-11-25 01:59 /usr/bin/mysql_convert_table_format -rwxr-xr-x 1 root root 23056 2009-11-25 01:59 /usr/bin/mysqld_multi -rwxr-xr-x 1 root root 13559 2009-11-25 01:59 /usr/bin/mysqld_safe -rwxr-xr-x 1 root root 71012 2009-11-25 01:59 /usr/bin/mysqldump -rwxr-xr-x 1 root root 6356 2009-11-25 01:59 /usr/bin/mysqldumpslow -rwxr-xr-x 1 root root 11648 2009-11-25 01:59 /usr/bin/mysql_explain_log -rwxr-xr-x 1 root root 3245 2009-11-25 01:59 /usr/bin/mysql_find_rows -rwxr-xr-x 1 root root 483 2009-11-25 01:59 /usr/bin/mysql_fix_extensions -rwxr-xr-x 1 root root 5834 2009-11-25 01:59 /usr/bin/mysql_fix_privilege_tables -rwxr-xr-x 1 root root 31485 2009-11-25 01:59 /usr/bin/mysqlhotcopy -rwxr-xr-x 1 root root 22720 2009-11-25 01:59 /usr/bin/mysqlimport -rwxr-xr-x 1 root root 13659 2009-11-25 01:59 /usr/bin/mysql_install_db -rwxr-xr-x 1 root root 6586 2009-11-25 01:59 /usr/bin/mysql_secure_installation -rwxr-xr-x 1 root root 16687 2009-11-25 01:59 /usr/bin/mysql_setpermission -rwxr-xr-x 1 root root 24436 2009-11-25 01:59 /usr/bin/mysqlshow -rwxr-xr-x 1 root root 14473 2009-11-25 01:59 /usr/bin/mysql_tableinfo -rwxr-xr-x 1 root root 152308 2009-11-25 01:59 /usr/bin/mysqltest -rwxr-xr-x 1 root root 38252 2009-11-25 01:59 /usr/bin/mysqltestmanager -rwxr-xr-x 1 root root 11956 2009-11-25 01:59 /usr/bin/mysqltestmanagerc -rwxr-xr-x 1 root root 10720 2009-11-25 01:59 /usr/bin/mysqltestmanager-pwgen -rwxr-xr-x 1 root root 1287788 2009-11-25 01:59 /usr/bin/mysql_tzinfo_to_sql -rwxr-xr-x 1 root root 52684 2009-11-25 01:59 /usr/bin/mysql_upgrade -rwxr-xr-x 1 root root 5753 2009-11-25 01:59 /usr/bin/mysql_upgrade_shell -rwxr-xr-x 1 root root 109092 2009-11-25 01:59 /usr/bin/mysql_waitpid -rwxr-xr-x 1 root root 3818 2009-11-25 01:59 /usr/bin/mysql_zap
[root@localhost kamailio-3.2.3]# ls /usr/bin/mysql* | xargs rm -f
[root@localhost kamailio-3.2.3]# ls /usr/bin/mysql* ls: cannot access /usr/bin/mysql*: No such file or directo [root@localhost kamailio-3.2.3]#
地址:http://www.mysql.com/downloads/mysql/#downloads选择的platform为source
code,我安装时的最新版本是mysql-5.5.24.tar.gz(需要注册, 这里可以免注册下载);
[zhang@localhost Code]# tar zxvf mysql-5.5.24.tar.gz [zhang@localhost Code]# cd mysql-5.5.24
[zhang@localhost mysql-5.5.24]# vim INSTALL-SOURCE 4443 2.9.2. Installing MySQL from a Standard Source Distribution 4459 In MySQL 5.5, CMake is used as the build framework on all 4460 platforms. The instructions given here should enable you to 4461 produce a working installation. For additional information on 4462 using CMake to build MySQL, see http://forge.mysql.com/wiki/CMake.[/code]
已经不是经典的 “./config; make ;make install” 的安装方法,需要cmake支持,本人系统自带了cmake
这里有一个下载链接,有各种cmake版本:http://download.chinaunix.net/download/0002000/1605.shtml
这里有安装示例,就按此安装咯。4478 and compile the distribution. For example, with a compressed tar 4479 file source distribution on Unix, the basic installation command 4480 sequence looks like this: 4481 # Preconfiguration setup 4482 shell> groupadd mysql 4483 shell> useradd -r -g mysql mysql 4484 # Beginning of source-build specific instructions 4485 shell> tar zxvf mysql-VERSION.tar.gz 4486 shell> cd mysql-VERSION 4487 shell> cmake . 4488 shell> make 4489 shell> make install 4490 # End of source-build specific instructions 4491 # Postinstallation setup 4492 shell> cd /usr/local/mysql 4493 shell> chown -R mysql . 4494 shell> chgrp -R mysql . 4495 shell> scripts/mysql_install_db --user=mysql 4496 shell> chown -R root . 4497 shell> chown -R mysql data 4498 # Next command is optional 4499 shell> cp support-files/my-medium.cnf /etc/my.cnf 4500 shell> bin/mysqld_safe --user=mysql & 4501 # Next command is optional 4502 shell> cp support-files/mysql.server /etc/init.d/mysql.server 4503
编译、安装:[root@localhost mysql-5.5.24]# cmake . [root@localhost mysql-5.5.24]# make[ 0%] Generating common.h [ 0%] Generating help.c [ 1%] Generating help.h [ 1%] Generating vi.h [ 1%] Generating emacs.h [ 1%] Generating fcns.c [ 1%] Generating fcns.h[ 29%] Built target comp_err Scanning dependencies of target GenError [ 29%] Generating ../include/mysqld_error.h, ../sql/share/english/errmsg.sys [ 29%] Built target GenError Scanning dependencies of target federated [ 30%] Building CXX object storage/federated/CMakeFiles/federated.dir/ha_federate[ 71%] Built target mysqlclient Scanning dependencies of target symlink_libmysqlclient_r.a [ 71%] Generating libmysqlclient_r.a [ 71%] Built target symlink_libmysqlclient_r.a Scanning dependencies of target symlink_libmysqlclient_r.so [ 71%] Generating libmysqlclient_r.so [ 71%] Built target symlink_libmysqlclient_r.so Scanning dependencies of target symlink_libmysqlclient_r.so.18 [ 71%] Generating libmysqlclient_r.so.18 [ 71%] Built target symlink_libmysqlclient_r.so.18 Scanning dependencies of target symlink_libmysqlclient_r.so.18.0.0 [ 71%] Generating libmysqlclient_r.so.18.0.0 [ 71%] Built target symlink_libmysqlclient_r.so.18.0.0
这时候会产生mysql的头文件和相关库,分别在当前目录的 ./include ./libmysql ./libmysqld ./libservices 的子目录下:[zhang@localhost mysql-5.5.24]$ ls ./include ./libmysql ./libmysqld ./libservices ./include: atomic m_ctype.h my_dir.h mysql_com.h my_uctype.h sslopt-case.h base64.h m_string.h my_getopt.h mysqld_ername.h my_user.h sslopt-longopts.h CMakeFiles my_aes.h my_global.h mysqld_error.h my_xml.h sslopt-vars.h cmake_install.cmake my_alarm.h myisam.h mysql_embed.h password.h t_ctype.h CMakeLists.txt my_alloc.h myisammrg.h mysql.h probes_mysql.d.base thr_alarm.h config.h my_atomic.h myisampack.h mysql.h.pp probes_mysql.h thr_lock.h decimal.h my_attribute.h my_libwrap.h mysql_time.h probes_mysql_nodtrace.h typelib.h errmsg.h my_base.h my_list.h mysql_version.h queues.h violite.h ft_global.h my_bit.h my_md5.h mysql_version.h.in rijndael.h welcome_copyright_notice.h hash.h my_bitmap.h my_net.h my_stacktrace.h service_versions.h heap.h my_compare.h my_nosys.h mysys_err.h sha1.h keycache.h my_compiler.h my_pthread.h my_sys.h sha2.h lf.h my_config.h my_rdtsc.h my_time.h sql_common.h Makefile my_dbug.h mysql my_tree.h sql_state.h ./libmysql: authentication_win conf_to_src.c libmysqlclient.a libmysqlclient.so libmysql.ver.in client_settings.h errmsg.c libmysqlclient_r.a libmysqlclient.so.18 Makefile CMakeFiles get_password.c libmysqlclient_r.so libmysqlclient.so.18.0.0 merge_archives_mysqlclient.cmake cmake_install.cmake libclientlib.a libmysqlclient_r.so.18 libmysql.def mysqlclient_depends.c CMakeLists.txt libmysql.c libmysqlclient_r.so.18.0.0 libmysql_exports_file.cc ./libmysqld: CMakeLists.txt embedded_priv.h emb_qcache.cc emb_qcache.h examples libmysqld.c libmysqld.def libmysqld.rc lib_sql.cc resource.h ./libservices: CMakeFiles CMakeLists.txt HOWTO Makefile my_thread_scheduler_service.c thd_wait_service.c cmake_install.cmake CTestTestfile.cmake libmysqlservices.a my_snprintf_service.c thd_alloc_service.c[root@localhost mysql-5.5.24]# make install
通过install的log 知道 相关的东西安装在/usr/local/mysql/,如果要调用Mysql的API,gcc的编译时要加相应的选项:
gcc -I/usr/local/mysql/include/ -L/usr/local/mysql/lib[root@localhost mysql]# cd /usr/local/mysql [root@localhost mysql]# ll total 76 drwxr-xr-x 2 root root 4096 2012-05-26 13:22 bin -rw-r--r-- 1 root root 17987 2012-04-19 19:01 COPYING drwxr-xr-x 4 root root 4096 2012-05-26 13:21 data drwxr-xr-x 2 root root 4096 2012-05-26 13:21 docs drwxr-xr-x 3 root root 4096 2012-05-26 13:21 include -rw-r--r-- 1 root root 7604 2012-04-19 19:01 INSTALL-BINARY drwxr-xr-x 3 root root 4096 2012-05-26 13:21 lib drwxr-xr-x 4 root root 4096 2012-05-26 13:22 man drwxr-xr-x 10 root root 4096 2012-05-26 13:22 mysql-test -rw-r--r-- 1 root root 2552 2012-04-19 19:01 README drwxr-xr-x 2 root root 4096 2012-05-26 13:22 scripts drwxr-xr-x 27 root root 4096 2012-05-26 13:22 share drwxr-xr-x 4 root root 4096 2012-05-26 13:22 sql-bench drwxr-xr-x 2 root root 4096 2012-05-26 13:22 support-files [root@localhost mysql]#
将mysql的路径添加到PATH变量中去:
修改profile文件
vi /etc/profileif ! echo $PATH | /bin/egrep -q "(^|: )$1($|: )" ; then if [ "$2" = "after" ] ; then PATH=$PATH: $1:/usr/local/mysql/bin else PATH=$1: $PATH:/usr/local/mysql/bin或者在/etc/profile文件最后添加如下两行:PATH=$PATH:/usr/local/mysql/bin export PATH执行下面的命令使所做的更改生效:[root@localhost mysql]# /etc/profile bash: /etc/profile: Permission denied [root@localhost mysql]# ll /etc/profile -rw-r--r-- 1 root root 1067 2012-05-27 01:12 /etc/profile [root@localhost mysql]# PATH=$PATH:/usr/local/mysql/bin [root@localhost mysql]# export PATH
安装貌似完成了!
然而由于这样或那样的原因,mysql总是不能正常运行,例如:[root@localhost mysql]# ./bin/mysql -u root mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) [root@localhost mysql]# [root@localhost mysql]# ps -aux | grep mysql Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ zhang 6330 0.0 0.0 4212 704 pts/1 S+ 23:46 0:00 grep mysql [root@localhost mysql]#
明显mysqld没有起来。“/etc/init.d/mysql start” 也不行,因为这个脚本是旧的mysql使用的。可以删掉。
按照源码中 INSTALL-SOURCE 4495行的指导:[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 strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: 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!
这段文字说得很清楚了,执行如下命令:[root@localhost mysql]# [root@localhost mysql]# chown -R mysql . [root@localhost mysql]# chgrp -R mysql . [root@localhost mysql]# scripts/mysql_install_db --user=mysql [root@localhost mysql]# chown -R root . [root@localhost mysql]# chown -R mysql data [root@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf [root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql.server [root@localhost mysql]# bin/mysqld_safe --user=mysql & [root@localhost mysql]#
You can start the MySQL daemon with:[root@localhost mysql]# ./bin/mysqld_safe & [1] 7085 [root@localhost mysql]# 120529 23:52:25 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'. 120529 23:52:25 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
查看log信息:[root@localhost mysql]# vim data/localhost.localdomain.err 120529 23:46:20 mysqld_safe mysqld from pid file /usr/local/mysql/data/localhost.localdomain.pid ended 120529 23:52:25 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data 120529 23:52:25 InnoDB: The InnoDB memory heap is disabled 120529 23:52:25 InnoDB: Mutexes and rw_locks use InnoDB's own implementation 120529 23:52:25 InnoDB: Compressed tables use zlib 1.2.3 120529 23:52:25 InnoDB: Initializing buffer pool, size = 128.0M 120529 23:52:25 InnoDB: Completed initialization of buffer pool 120529 23:52:25 InnoDB: highest supported file format is Barracuda. InnoDB: Log scan progressed past the checkpoint lsn 48941 120529 23:52:25 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Restoring possible half-written data pages from the doublewrite InnoDB: buffer... InnoDB: Doing recovery: scanned up to log sequence number 1595675 120529 23:52:25 InnoDB: Starting an apply batch of log records to the database... InnoDB: Progress in percents: 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 InnoDB: Apply batch completed 120529 23:52:25 InnoDB: 1.1.8 started; log sequence number 1595675 120529 23:52:25 [Note] Server hostname (bind-address): '(null)'; port: 3306 120529 23:52:25 [Note] - '(null)' resolves to '0.0.0.0'; 120529 23:52:25 [Note] - '(null)' resolves to '::'; 120529 23:52:25 [Note] Server socket created on IP: '0.0.0.0'. 120529 23:52:25 [Note] Event Scheduler: Loaded 0 events 120529 23:52:25 [Note] /usr/local/mysql/bin/mysqld: ready for connections. Version: '5.5.24-log' socket: '/tmp/mysql.sock' port: 3306 Source distribution
mysqld_safe & 和 /etc/init.d/mysql.server [restart|start|stop]都可以操作mysqld,
并且可以看到mysql的启动参数真是很多:[root@localhost mysql]# ps -aux | grep mysql Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ root 7085 0.0 0.1 4812 1224 pts/1 S May29 0:00 /bin/sh ./bin/mysqld_safe mysql 7312 0.0 3.9 327252 40876 pts/1 Sl May29 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/localhost.localdomain.err --pid-file=/usr/local/mysql/data/localhost.localdomain.pid --socket=/tmp/mysql.sock --port=3306 zhang 8659 0.0 0.0 4212 708 pts/2 S+ 00:30 0:00 grep mysql [root@localhost mysql]# [root@localhost mysql]# /etc/init.d/mysql.server restart Shutting down MySQL. [ OK ] Starting MySQL. [ OK ] [root@localhost mysql]# [root@localhost mysql]#
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'[root@localhost mysql]# ./bin/mysqladmin -u root password mypassword [root@localhost mysql]# ./bin/mysqladmin -u root -h localhost.localdomain password mypassword ./bin/mysqladmin: connect to server at 'localhost.localdomain' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)' [root@localhost mysql]#
当出现下面的文字时,我相信大功告成啦:[root@localhost mysql]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.5.24-log Source distribution Copyright (c) 2000, 2011, 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. mysql> exit Bye [root@localhost mysql]#
//TODO
相关文章推荐
- Fedora10安装vmware-tools后系统无法正常启动的解决方法
- 安装widows mysql 免安装版(zip) 步骤详解 以及遇到问题解决 以及忘记密码的修改方法
- MYSQL安装时解决要输入current root password的方法(彻底卸载重装Mysql终极总结)
- 安装widows mysql 免安装版(zip) 步骤详解 以及遇到问题解决 以及忘记密码的修改方法
- 安装widows mysql 免安装版(zip) 步骤详解 以及遇到问题解决 以及忘记密码的修改方法
- 安装widows mysql 免安装版(zip) 步骤详解 以及遇到问题解决 以及忘记密码的修改方法
- ubuntu下彻底卸载mysql后重新安装——解决忘记mysql的root密码问题
- 安装widows mysql 免安装版(zip) 步骤详解 以及遇到问题解决 以及忘记密码的修改方法
- Fedora 10下安装Mplayer(添加源和解决错误问题)
- window XP安装 apache 2.2.19 + 要下载二进制的php5.3.6 + Mysql 5.5配置(彻底解决 Fatal error: Class 'mysqli' not found in )
- linux 安装mysql 5.7.21详解以及安装过程中所遇问题解决
- fedora 10 下安装systemtap详解
- 安装widows mysql 免安装版(zip) 步骤详解 以及遇到问题解决 以及忘记密码的修改方法
- 安装widows mysql 免安装版(zip) 步骤详解 以及遇到问题解决 以及忘记密码的修改方法
- 安装widows mysql 免安装版(zip) 步骤详解 以及遇到问题解决 以及忘记密码的修改方法
- 安装widows mysql 免安装版(zip) 步骤详解 以及遇到问题解决 以及忘记密码的修改方法
- fedora 11-Ubuntu9-10安装vmware tools 解决文件共享的问题 (转)
- 安装widows mysql 免安装版(zip) 步骤详解 以及遇到问题解决 以及忘记密码的修改方法
- 安装widows mysql 免安装版(zip) 步骤详解 以及遇到问题解决 以及忘记密码的修改方法