当前位置: 首页 >数据库 > ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/usr/local/mysql/tmp/mysql.sock'

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/usr/local/mysql/tmp/mysql.sock'

查看是否开启服务

# ps -ef | grep mysqlroot  5605  5457  0 11:45 pts/200:00:00 grep mysql

查看my.cnf

# cat /etc/my.cnf # Example MySQL config file for small systems.## This is for a system with little memory (<= 64M) where MySQL is only used# from time to time and it's important that the mysqld daemon# doesn't use much resources.## MySQL programs look for option files in a set of# locations which depend on the deployment platform.# You can copy this option file to one of those# locations. For information about these locations, see:# http://dev.mysql.com/doc/mysql/en/option-files.html## In this file, you can use all long options that a program supports.# If you want to know which options a program supports, run the program# with the "--help" option.# The following options will be passed to all MySQL clients[client]#password	= your_passwordport		= 3306socket  = /usr/local/mysql/tmp/mysql.sock# Here follows entries for some specific programs# The MySQL server[mysqld]port		= 3306socket  = /usr/local/mysql/tmp/mysql.sockskip-exteal-lockingkey_buffer_size = 16Kmax_allowed_packet = 1Mtable_open_cache = 4sort_buffer_size = 64Kread_buffer_size = 256Kread_d_buffer_size = 256Knet_buffer_length = 2Kthread_stack = 128K# Don't listen on a TCP/IP port at all. This can be a security enhancement,# if all processes that need to connect to mysqld run on the same host.# All interaction with mysqld must be made via Unix sockets or named pipes.# Note that using this option without enabling named pipes on Windows# (using the "enable-named-pipe" option) will render mysqld useless!# #skip-networkingserver-id	= 1# Uncomment the following if you want to log updates#log-bin=mysql-bin# binary logging format - mixed recommended#binlog_format=mixed# Causes updates to non-transactional engines using statement format to be# written directly to binary log. Before using this option make sure that# there are no dependencies between transactional and non-transactional# tables such as in the statement INSERT INTO t_myisam SELECT * FROM# t_innodb; otherwise, slaves may diverge from the master.#binlog_direct_non_transactional_updates=TRUE# Uncomment the following if you are using InnoDB tables#innodb_data_home_dir = /usr/local/mysql/data#innodb_data_file_path = ibdata1:10M:autoextend#innodb_log_group_home_dir = /usr/local/mysql/data# You can set .._buffer_pool_size up to 50 - 80 %# of RAM but beware of setting memory usage too high#innodb_buffer_pool_size = 16M#innodb_additional_mem_pool_size = 2M# Set .._log_file_size to 25 % of buffer pool size#innodb_log_file_size = 5M#innodb_log_buffer_size = 8M#innodb_flush_log_at_trx_commit = 1#innodb_lock_wait_timeout = 50[mysqldump]quickmax_allowed_packet = 16M[mysql]no-auto-rehash# Remove the next comment character if you are not familiar with SQL#safe-updates[myisamchk]key_buffer_size = 8Msort_buffer_size = 8M[mysqlhotcopy]interactive-timeout

启动mysql服务器

# ./mysqld --defaults-file=/etc/my.cnf --user=root &

查看是否开启服务

# ps -ef | grep mysqlroot  5359 1  0 11:42 ?00:00:00 ./mysqld --defaults-file=/etc/my.cnf --user=rootroot  5605  5457  0 11:45 pts/200:00:00 grep mysql

作者:TBHacker
来源链接:https://www.cnblogs.com/jiqing9006/p/10037434.html

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaclub.cn/database/117875.html

分享给朋友:

“ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/usr/local/mysql/tmp/mysql.sock'” 的相关文章