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
Related
ok here's the thing I tried installing MySQL-server and it did install perfectly no problem there.
later I had had to format my system and then when I tried to install it, it did install but it did not prompt for the root password. when I later tried to reset the root password here's the problem I get
user#user:~$ sudo /etc/init.d/mysql stop
[ ok ] Stopping mysql (via systemctl): mysql.service.
user#user:~$ sudo mysqld --skip-grant-tables &
[3] 13831
user#user:~$ mysql -u root -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
[3] Exit 1 sudo mysqld --skip-grant-tables
I tried resolving the 2002 error but I am unable to do so. any help will be appreciated.
from what I understand I should not get the 2002 error to proceed further
The error is probably due to error in installation. Try the following:
Ensure that my MySQL service is running by executing the following command in the terminal:
$ sudo service mysql start
Verify the state of the process:
$ ps -A|grep mysql
$ ps -A|grep mysqld
Then kill the process with the following command:
$ sudo pkill mysql
$ sudo pkill mysqld
Finally restart the service:
$ sudo service mysql restart
And run the following command:
$ mysql -u root -p
Step#1: Run this command:
sudo mysql_secure_installation
Step#2: press n
Step#3: input your password.
Step#4: press y for until it says All done!
or follow this video tutorial
Also to change the password use this command:
mysql> ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';
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 have MySQL restarted on Ubuntu (Version 16), and the login command hangs for unknown reasons.
ubuntu#ip-172-31-12-122:~$ sudo /etc/init.d/mysql restart
[ ok ] Restarting mysql (via systemctl): mysql.service.
ubuntu#ip-172-31-12-122:~$
ubuntu#ip-172-31-12-122:~$
ubuntu#ip-172-31-12-122:~$ sudo mysqld -u root -p
It looks like you are starting a new instance of the server in the foreground ?
sudo mysqld -u root -p
https://dev.mysql.com/doc/refman/5.7/en/server-options.html
If you want to login to your running instance
mysql -u root -p
https://dev.mysql.com/doc/refman/5.7/en/mysql.html
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.
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.