Skip to content

Instantly share code, notes, and snippets.

@slawosz
Created October 4, 2016 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slawosz/5cb3699d968e6e4d50b62f6baa112c1d to your computer and use it in GitHub Desktop.
Save slawosz/5cb3699d968e6e4d50b62f6baa112c1d to your computer and use it in GitHub Desktop.

How to connect to mysql? Normally, this would be enough:

$ mysql -uroot -p this is simplest way. If your user is not root, than check your user name and substitute root with this username.

If you want to connect to database after login, do $ mysql -uroot -p mydbname

To apply dump, do:

$ mysql -uroot -p mydbname < dumpfile.sql

In case where dump file consists db name, do (same command, no db name, but above is more likely):

$ mysql -uroot -p < dumpfile.sql

To create database, you can use:

$ mysql -uroot -e 'create database some_database_name'

In case of problems with password, stackoverflow will help: http://stackoverflow.com/questions/16556497/how-to-reset-or-change-the-mysql-root-password

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment