Friday 8 May 2020

Setup MySQL on UBUNTU

MySQL Workbench was not the best tool in Ubuntu
- Ctrl-ENter sometimes ran previous query not current selected query
- Screen too big
- MOved to PHpSTorm


Open local host
Database >> +Datasource >> MySQL


Loading DOcument - MySQL Workbench

<Where is file>
Dropbox >> TechDoc_Cascade >> AWS_all >> sql
I don't know why I put it there.

<files>
migration1.sql
migtration2.sql


<how to import excel file>

1. COnvert customer's .xlsx file into .csv >> so much convenient later.

2. MySQL WOrkbench >> Server >> Data IMport >> select .csv file. (x)
2. Choose schema, eg, matthew_schema >> Tables >> right clikc >> 'Table Data IMport' (o)

3. Start import
4. Review 'text' data (date data should be exported to text data first for more peaceful import)
5. Keep the table name as raw, eg, JObLIst_import. We will keep this as reference, and create a new table any way.

6. ONce import is finished apply migration1.sql


<MySQL Workbench>
Edit >> Preference >> SQL Editor >> untic 'Safe UPdtes'
SQL Editor >> SQL Execution >> 'Limit ROws' >> 10,000


<Change root user password>
This site messed me up:
https://www.a2hosting.com/kb/developer-corner/mysql/reset-mysql-root-password

This site saved me:
https://stackoverflow.com/questions/30692812/mysql-user-db-does-not-have-password-columns-installing-mysql-on-osx

Below code of the 1st url seems to be old one.

matthew@SYDNEY-D-003:~/work2/$ mkdir -p /var/run/mysqld
mkdir: cannot create directory ‘/var/run/mysqld’: Permission denied
matthew@SYDNEY-D-003:~/work2/$ sudo mkdir -p /var/run/mysqld
matthew@SYDNEY-D-003:~/work2/$ chown mysql:mysql /var/run/mysqld
chown: changing ownership of '/var/run/mysqld': Operation not permitted
matthew@SYDNEY-D-003:~/work2/$ sudo chown mysql:mysql /var/run/mysqld
matthew@SYDNEY-D-003:~/work2/$ sudo mysqld_safe --skip-grant-tables &
[2] 19349
matthew@SYDNEY-D-003:~/work2/$ 2020-05-09T06:27:16.694377Z mysqld_safe Logging to syslog.
2020-05-09T06:27:16.698323Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2020-05-09T06:27:16.728153Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

<MySQL errors>
Access denied for user 'user'@'localhost' (using password: YES) (SQL: select * from `authors`)
>> create user

mysql seems no password required.
if 'mysql -u root -p' doesn't work with you root password you remeber, just type in 'mysql'.

 Even when I typed in correct password, it was returning error message.
ON the contrary, when I just typed in 'mysql', voila!!

 You could even update root user's password.





No comments:

Post a Comment