ERROR 2002 (HY000) on installing moodle on ubuntu 14.04 - mysql

I follow the steps in:
http://docs.moodle.org/27/en/Step-by-step_Install_Guide_for_Ubuntu
and in step 6, after typing the following command :
mysql -u root -p
I have this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
And when I go to the '/var/run/mysqld I can't found mysqld.sock although in file(/etc/mysql/my.cnf)the :
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
So why this error?

I would recommend following the installation instruction for Apache/MySql/PHP at :
https://help.ubuntu.com/community/ApacheMySQLPHP
Basically
sudo apt-get install lamp-server^
Then follow the instructions for installing Moodle
http://docs.moodle.org/27/en/Installing_Moodle

Related

Why mysqld_multi can't start mysql?

In my my.cnf, I write:
[mysqld_multi]
mysqld = /usr/local/Cellar/mysql/5.7.11/bin/mysqld_safe
mysqladmin = /usr/local/Cellar/mysql/5.7.11/bin/mysqladmin
user = root
password =
[mysqld1]
pid-file = /usr/local/etc/mysql/mysqld.pid
socket = /usr/local/etc/mysql/mysqld.sock
port = 3306
datadir = /usr/local/var/mysql
log-bin=mysql-bin
server-id=1
[mysqld2]
pid-file = /usr/local/etc/mysql/mysqld1.pid
socket = /usr/local/etc/mysql/mysqld1.sock
port = 3307
datadir = /usr/local/var/mysql1
server-id=2
language=/usr/local/Cellar/mysql/5.7.11/share/mysql/english
user=mysql
Then I execute mysqld_multi start 2, and I get the error info:
Installing new database in /usr/local/var/mysql1
2016-09-19 19:37:16 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2016-09-19 19:37:16 [ERROR] Can't locate the language directory.
FATAL ERROR: Tried to start mysqld under group [mysqld2],
but no data directory was found or could be created.
data directory used: /usr/local/var/mysql1
I can't start the mysql process, so what's the problem? It seems the directory /usr/local/var/mysql1 has some problems, but the directory exists, it's confused.
It seems like mysqld_multi wasn't fixed to use mysqld --initialize.
You will have to run mysqld --initialize along with all directory related options in my.cnf for that server.
(from comment)
You can also fix the mysqld_multi script following the instructions in Running two instances of mysql.

Mysql: CanĀ“t start Server debian wheezy

Everytime i try to start my mysql service i get the same error
Error message:
150130 15:56:31 [ERROR] Can't start server: Bind on TCP/IP port: Cannot assign requested address
150130 15:56:31 [ERROR] Do you already have another mysqld server running on port: 3305 ?
150130 15:56:31 [ERROR] Aborting
My Error log is empty
Conf file snippet:
[client]
port = 3305
socket = /var/run/mysqld/mysqld.sock
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3305
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
Sorry for my bad english
Complete Conf file
Looks like your port(3305) is occupied by another process.. you can :
1) switch to different port
2) kill/modify the process holding this port
(look it up using:
lsof -i :3305
)
in addition, this could be the cause of it (as one stated in this post) :
Change bind-address to 127.0.0.1 instead of localhost
Skipping network worked for me :
# echo "skip-networking" >> /etc/mysql/my.cnf
Then start mysql again.

OpenWrt install mysql-server

I am trying to install mysql-server on OpenWrt.
mysql_install_db --force gives me error:
/usr/bin/my_print_defaults: can't load library 'libnsl.so.0'
FATAL ERROR: Could not find /usr/lib/mysqld
If you compiled from source, you need to run 'make install' to copy
the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top level
of the extracted archive, or pass the --basedir option pointing to
that location.
I have install Libc but I can' find libnsl.so.0 under /usr/lib
I have my.cnf under /etc/
Content of my.cnf:
root#OpenWrt:/etc# cat my.cnf
[client]
port = 3306
socket = /var/run/mysqld.sock
[mysqld]
user = root
socket = /var/run/mysqld.sock
port = 3306
basedir = /usr
############ Don't put this on the NAND #############
# Figure out where you are going to put the databases
# And run mysql_install_db --force
datadir = /mnt/data/mysql/
######### This should also not go on the NAND #######
tmpdir = /mnt/data/tmp/
skip-external-locking
bind-address = 127.0.0.1
# Fine Tuning
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
# The following can be used as easy to replay backup logs or for replication.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
#expire_logs_days = 10
#max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
[isamchk]
key_buffer = 16M
I also created mkdir /usr/lib/mysqld folder.
drwxr-xr-x 2 root root 4096 Mar 19 17:39 mysqld
Then I get error:
/usr/bin/my_print_defaults: can't load library 'libnsl.so.0'
Installing MySQL system tables...
/usr/bin/mysql_install_db: line 418: /usr/lib/mysqld: Permission denied
Installation of system tables failed! Examine the logs in
/var for more information.
You can try to start the mysqld daemon with:
shell> /usr/lib/mysqld --skip-grant &
and use the command line tool /usr/bin/mysql
to connect to the mysql database and look at the grant tables:
shell> /usr/bin/mysql -u root mysql
mysql> show tables
Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /var that may be helpful.
Please consult the MySQL manual section
'Problems running mysql_install_db', and the manual section that
describes problems on your OS. Another information source are the
MySQL email archives available at http://lists.mysql.com/.
Please check all of the above before mailing us! And remember, if
you do mail us, you MUST use the /usr/bin/mysqlbug script!
I also tried:
cd /usr/lib
wget http://trac.augsburg.freifunk.net/export/3/trunk/freifunk-openwrt-kit-1.6.20-de/root/lib/libnsl.so.0 libnsl.so.0
Then I get error:
'/usr/lib/libnsl.so.0' is not an ELF file
I do not know what to do any more.
Please give me some idea! Thanks!
UPDATE:
I have updated opkg.conf
Removed mysql-server
And istall mysql-server from new url provided in opkg.conf
mysql_install_db works now great.
I can start mysqld without error BUT
I CANT CHANGE ROOT PASSWORD
/usr/bin/mysqladmin -u root password 'xxxxxxxxx'
/usr/bin/mysqladmin: can't load library 'libnsl.so.0'
any other option to change mysql root password?
UPDATE2:
Install: http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/libmysqlclient_5.1.53-7_ar71xx.ipk
WORKS!!!!

multiple instances mysql on ubuntu error

I have been trying to make multiple instances of mysql on ubuntu. These are the steps I followed.
mv /etc/init.d/mysql /etc/init.d/mysql_mono.server
cp /usr/share/mysql/mysqld_multi.server /etc/init.d/mysql
With your favourite text editor, edit /etc/init.d/mysql, then find the lines:
basedir=/usr/local/mysql
bindir=/usr/local/mysql/bin
And change to:
basedir=/usr
bindir=/usr/bin
If your have a root password in localhost, edit the file /usr/bin/mysqld_multi, then find the line:
$opt_password = undef()
And change to:
$opt_password = "password"
changing "password" by the 'root'#'localhost' password.
Now create a database directory for each additional mysqld instance:
# cp -pr /var/lib/mysql /var/lib/mysql1
# cp -pr /var/lib/mysql /var/lib/mysql2
My configuration file(my.cnf) is:
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld1]
user = root
pid-file = /var/run/mysqld1.pid
socket = /var/run/mysqld1.sock
port = 3301
datadir = /var/lib/mysql1
log = /var/log/mysql/mysql1.log
server-id = 1
log_bin = /var/log/mysql/mysql1-bin.log
[mysqld2]
user = root
pid-file = /var/run/mysqld2.pid
socket = /var/run/mysqld2.sock
port = 3302
datadir = /var/lib/mysql2
log = /var/log/mysql/mysql2.log
server-id = 2
log_bin = /var/log/mysql/mysql2-bin.log
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
log_error = /var/log/mysql/error.log
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
[isamchk]
key_buffer = 16M
``!includedir /etc/mysql/conf.d/
Still I get this error when i run following command:
mysql --socket=/var/run/mysqld1.sock -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld1.sock' (2)
via http://dev.mysql.com/doc/refman/5.5/en/multiple-unix-servers.html
One way is to run multiple MySQL instances on Unix is to compile
different servers with different default TCP/IP ports and Unix socket
files so that each one listens on different network interfaces.
Compiling in different base directories for each installation also
results automatically in a separate, compiled-in data directory, log
file, and PID file location for each server.
Assume that an existing 5.1 server is configured for the default
TCP/IP port number (3306) and Unix socket file (/tmp/mysql.sock). To
configure a new 5.5.35 server to have different operating parameters,
use a CMake command something like this:
shell> cmake . -DMYSQL_TCP_PORT=port_number \
-DMYSQL_UNIX_ADDR=file_name \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.35

While connecting to mysql showing socket error

I have mysql server installed and it contains data also. I was trying to connect to mysql from ruby code. For that purpose I installed mysql gem using gem install mysql. The connection part in my program is giving below
require 'rubygems'
require 'mysql'
require 'csv'
$user_name = "root"
$pas_wrd = "password"
def mysql_connect(db_name)
begin
db = Mysql.real_connect("localhost", "#{$user_name}", "#{$pas_wrd}", "#{db_name}")
return db
rescue Mysql::Error => e
puts "Error code: #{e.errno}"
puts "Error message: #{e.error}"
puts "Error SQLSTATE: #{e.sqlstate}" if e.respond_to?("sqlstate")
end
end
It was written some day before and done the job. But when I try to use the same code It shows a mysql gem error,something like 'initialize' not found. By searching I found a solution like re-installing the gem. for re-installing I user the command rvmsudo gem install mysql. The above problem was solved. But it showing another error like
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I tried manually using mysql -u root -p
it is also showing the same error.
My mysql my.cnf content is given below.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
tmpdir = /home/presoft/Documents
skip-external-locking
The mysql is not running in my system.
ps aux | grep mysql
presoft 3823 0.0 0.0 4368 816 pts/0 S+ 10:41 0:00 grep --color=auto mysql
I tried to start using using sudo /etc/init.d/mysql start which gave the result of
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mysql
start: Job failed to start
Can any one help me to find a solution because db containing large amount of valuable data.
Thanks
Regards.
Use
service mysql start
This will start mysql service. newer linux machine consider mysql as service
I solved the problem from the above answer tip. The problem was my mysql server was corrupted.
So I first run the command
sudo apt-get purge mysql-common mysql-server
It will remove the all mysql files and configurations with out deleting the data. After running please carefully watch the process and do the need full any warning or error come.
I got a warning like
dpkg: warning: while removing mysql-common, directory '/etc/mysql' not empty so not removed.
So I removed the file and re run the above command. After the successful execution. I re-installed the mysql using
sudo apt-get install mysql-common mysql-server
then set the root password. After getting in to server The data is safe.