简体   繁体   中英

Where to issue mysql commands?

I am new to using mysql. First I connect to my web hosting SSH and then I use the following command to connect to the mysql server:

mysql -u mysqlusername -h server_ip -p (the server is not localhost, it is a remote server)

Then it prompts for the password, I enter it, and I am connected. I receive a mysql> prompt

Now I am trying to import a sql dump while preserving the charset. I've looked around on the internet and apparently the command to use is

mysql -uUSERNAME -pPASSWORD –default-character-set=utf8 USER_DATABASE < backup.sql

but since I am already connected, I try to issue: –default-character-set=utf8 USER_DATABASE < backup.sql but a new line appears to enter a new command instantly and its not possible that the command has been executed because the sql backup is 20 mb. It does not do anything.

在此处输入图片说明

I am having encoding issues with my website. The dump is in utf-8, all the special charachters show up as they should when I view the file using notepad, but for some reason as soon as I import the dump using phpmyadmin's import menu, I browse the tables and all the special characters are scrambled. When I access the website the characters are scrambled. I added AddDefaultCharset UTF-8 to htaccess file, but to no avail. This is why I want to try to import the dump using mysql command.

You see there is a command

mysql -u mysqlusername -h server_ip -p

and another one

mysql -uUSERNAME -pPASSWORD –-default-character-set=utf8 USER_DATABASE < backup.sql

Did you try to merge them?

Such as

mysql -u mysqlusername -h server_ip -p –-default-character-set=utf8 USER_DATABASE < backup.sql

?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM