I am new to AWS EC2 and I wanted to connect the Mysql to upload an sql file.
I used bitvize sftp to upload the files and with this ftp i have a commandline window to work around the server.
Here i am trying to connect the mysql using commands like -
Verify that mysql server is up and running first by a 'ps -ef | grep mysql'
ec2-user 22352 254217 0 10:58 pts/0 00:00:00 grep --color=auto mysql
root 223349 1 0 2016 ? 00:00:00 /bin/sh /usr/libexec/mysql55/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql 223349 226349 0 2016 ? 00:33:26 /usr/libexec/mysql55/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
Then i tried the command /usr/bin/mysql -uroot -p
it prompts the password.But i don't know the password or am i doing the correct method?
The bottom line is i need to create a db and user and upload an sql file for that DB.
How could i do it?
If the root user doesn't have a password, then don't use the -p option.
Related
My XAMPP mysql server is working fine
then I download the separate mysql from oracle and installed it. It is running fine but after some days I cant start it as :> mysql -u root
and in xampp mysql server it is also not working it shows stopped always.
I am providing all the commands that I tried from google as well as StackOverflow
and also I am providing all results of all commands.
Please refer commands before answering.
Number indicates ways that I tried.
1.> `mysql -u root -p`
2.> `mysql -u root`
3.> `sudo su`
3.1.> `ps aux | grep mysql`
3.2.> `kill -9 8306`
4.> `sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start`
5.> `sudo killall mysqld`
6.> Changing content of file as: `innodb_force_recovery = 1` in
`/Applications/XAMPP/xamppfiles/etc/my.cnf`
7.> Changing content of file as: read only permission in
`/Applications/XAMPP/xamppfiles/etc/my.cnf`
8.> Port changed from 3306 to 3307 3308 but nothing is happened
9.> Activity manager : mysql service is. not listed
10.> Reinstalled XAMPP
I followed this 10 ways so please dont answer on this 10 ways
Result of commands :
<.1.
Pratiks-MacBook-Pro:~ pratik$ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock' (2 "No such file or directory")
<.2.
Pratiks-MacBook-Pro:~ pratik$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock' (2 "No such file or directory")
<.3.
Pratiks-MacBook-Pro:~ pratik$ sudo su
Password:
sh-3.2# ps aux | grep mysql
root 8306 0.0 0.0 4258468 180 s000 U+ 11:35AM 0:00.00 grep mysql
sh-3.2# kill -9 8306
sh: kill: (8306) - No such process
sh-3.2#
<.4.
Pratiks-MacBook-Pro:~ pratik$ sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
Starting MySQL
.2018-03-13 11:44:29 8513 mysqld_safe Logging to '/Applications/XAMPP/xamppfiles/var/mysql/Pratiks-MacBook-Pro.local.err'.
2018-03-13 11:44:29 8513 mysqld_safe Starting mysqld daemon with databases from /Applications/XAMPP/xamppfiles/var/mysql
ERROR!
<.5.
Pratiks-MacBook-Pro:~ pratik$ sudo killall mysqld
No matching processes were found
I knew the question I am asking is somewhat alike with other guys, but my case is a little different:
I did not install mysql-server using yum, nor did I install it with rpm or compile-makeinstall.
I simply downloaded the compressed precompiled binary from the official website:
http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.73-linux-x86_64-glibc23.tar.gz
So, there is no /etc/init.d/mysqld, the "service mysqld start/stop/restart" could not work.
I unarchived it and initialized the DB with:
./scripts/mysql_install_db
then start it with:
./bin/mysqld_safe &
everything work fine till now, but when I tried to connect it using mysql, it prompted:
# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
The data directory was changed to:
drw-rw-rw- 4 mysql mysql 4096 Jan 3 14:03 mysql
The following stop command also could not work:
# mysqladmin shutdown
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
The mysqld_safe process and mysqld process are all working fine:
# ps -ef | grep mysqld
root 10977 5685 0 14:03 pts/2 00:00:00 /bin/sh ./bin/mysqld_safe
mysql 11154 10977 0 14:03 pts/2 00:00:00 /root/mysql-5.1.73-linux-x86_64-glibc23/bin/mysqld
--basedir=/root/mysql-5.1.73-linux-x86_64-glibc23
--datadir=/var/lib/mysql --user=mysql
--log-error=/var/log/mysqld.log
--pid-file=/var/run/mysqld/mysqld.pid
--socket=/var/lib/mysql/mysql.sock
root 11650 5685 0 14:26 pts/2 00:00:00 grep mysqld
some config information in the /etc/my.cnf is :
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
old_passwords=1
# ps -ef | grep mysqld
root 10977 5685 0 14:03 pts/2 00:00:00 /bin/sh ./bin/mysqld_safe
mysql 11154 10977 0 14:03 pts/2 00:00:00 /root/mysql-5.1.73-linux-x86_64-glibc23/bin/mysqld
--basedir=/root/mysql-5.1.73-linux-x86_64-glibc23
--datadir=/var/lib/mysql --user=mysql
--log-error=/var/log/mysqld.log
--pid-file=/var/run/mysqld/mysqld.pid
--socket=/var/lib/mysql/mysql.sock
your socket is at /var/lib/mysql/mysql.sock
guess you are using /usr/bin/mysql
to connect to mysql, you can update /etc/my.cnf, set socket=/var/lib/mysql/mysql.sock for [mysql] section
[mysql]
socket=/var/lib/mysql/mysql.sock
To fix mysqladmin you need to add the section [mysqladmin] also
[mysqladmin]
socket=/var/lib/mysql/mysql.sock
Alternatively you can add [client], it should work for both mysql and mysqladmin
[client]
socket=/var/lib/mysql/mysql.sock
Don't you need to do a
mysql.server start
When I run apt-get install percona-server-server-5.6, the percona server gets installed and started. The processes running (ps -ef | grep mysql) look like this (HOSTNAME is obfuscated):
root 14309 1 0 23:54 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/HOSTNAME.pid
mysql 14413 14309 3 23:54 ? 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/lib/mysql/HOSTNAME.err --pid-file=/var/lib/mysql/HOSTNAME.pid
My question is where is this default PID file coming from? There is no my.cnf file under /etc/mysql and the my.cnf file under /usr doesn't have any of this information. This is causing a problem ebcause when I deploy my configuration file and try to restart the server, the box obviously doesn't work. I believe the correct default for the PID file is /var/run/mysqld/mysqld.pid.
Looks like this is being set in the init mysql file.
I have installed zend server on my iMac. I can log on to zend server and i can log in to phpmyadmin, using user: root pw: (blank)
However. I am desperately trying to open mysql using the terminal. I have tried for 3h now and wiht all kinds of pathways and sudo-whatnot..
This i get when:
Williams-iMac:mysql uglyface$ cd /usr/local/zend/mysql/bin
Williams-iMac:bin uglyface$ ls
innochecksum mysql_config mysqlaccess.conf mysqlhotcopy
msql2mysql mysql_convert_table_format mysqladmin mysqlimport
my_print_defaults mysql_find_rows mysqladmin.client mysqlmanager
myisam_ftdump mysql_fix_extensions mysqlbinlog mysqlshow
myisamchk mysql_fix_privilege_tables mysqlbug mysqlslap
myisamlog mysql_secure_installation mysqlcheck mysqltest
myisampack mysql_setpermission mysqld mysqltest_embedded
mysql mysql_tzinfo_to_sql mysqld-debug perror
mysql.client mysql_upgrade mysqld_multi replace
mysql.server mysql_waitpid mysqld_safe resolve_stack_dump
mysql_client_test mysql_zap mysqldump resolveip
mysql_client_test_embedded mysqlaccess mysqldumpslow setup_mysql.sh
So in here i can se mysql, but i haven been able to do anything with it. I am sorry for way of displaying the output i get. I tried to get it to display differently but with no success as you can see...
Do any one know what i can do, so that i can log in to my mysql?
/W
edit: There is no mysql located in /usr/local/bin...
If mysql is running (you start it with the zend server controller), you should be able to do:
/usr/local/zend/mysql/bin/mysql -uroot -p <your dbname>
You can verify mysqld is running by a simple
ps -ef | grep mysqld
If it's running, you'll see more than just your grep command in the resulting process list.
I have MAMP installed in my Applications folder on my Mac, and the project files inside the htdocs folder on MAMP.
If I want to connect to MySQL from the command line, what would I type into the command line?
Note, it says that to connect to MySQL from my scripts I need to use the following, but I'm not sure how it will look from the command line
Host localhost
Port 8889
User root
Password root
EDIT - after running sudo ps -aef | grep mysqld in my terminus, I got the following.
501 528 1 0 0:00.02 ?? 0:00.02 /bin/sh /Applications/MAMP/Library/bin/mysqld_safe --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --lower_case_table_names=0 --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log
501 598 528 0 0:00.77 ?? 0:03.72 /Applications/MAMP/Library/libexec/mysqld --basedir=/Applications/MAMP/Library --datadir=/Applications/MAMP/db/mysql --user=mysql --lower_case_table_names=0 --log-error=/Applications/MAMP/logs/mysql_error_log.err --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --socket=/Applications/MAMP/tmp/mysql/mysql.sock --port=8889
501 6083 4176 0 0:00.00 ttys000 0:00.00 grep mysqld
EDIT
working answer
$ mysql --host=127.0.0.1 --port=8889 --user=root -p
Enter password:
mysql --host=127.0.0.1 --port=8889 --user=root -p
or
mysql --socket=/Applications/MAMP/tmp/mysql/mysql.sock --user=root -p
The default password for the mysql root account under MAMP is root, so when it prompts for the password, enter "root" (but don't include the quotes). So, if you want to provide the password right on the main command line, versus prompting for it, do as follows:
mysql --socket=/Applications/MAMP/tmp/mysql/mysql.sock --user=root --password=root