Jump to content

Narcis

Members
  • Posts

    12
  • Joined

  • Last visited

Posts posted by Narcis

  1. I try to do the Node.js MySQL tutorial. https://www.w3schools.com/nodejs/nodejs_mysql.asp

    - I have downloaded MySQL from here: https://dev.mysql.com/downloads/mysql/

    - I clicked on the file and installed it.

    - Now I have it in my Mac System Preferences > MySQL

    - I put that in Terminal: npm install mysql

    - In demo_db_connection.js I put

    var mysql = require('/Users/myName/node_modules/mysql');
    
    var con = mysql.createConnection({
      host: "localhost",
      user: "root",
      password: "myPassword"
    });
    
    con.connect(function(err) {
      if (err) throw err;
      console.log("Connected!");
    });

    - Then in Termimal: cd (folder where I have the file)

    - node demo_db_connection.js

    - It gives me a long error. At the end: 

      code: 'ER_NOT_SUPPORTED_AUTH_MODE',
      errno: 1251,
      sqlMessage: 'Client does not support authentication protocol requested by server; consider upgrading MySQL client',
      sqlState: '08004',
      fatal: true

    I remember the password but I am not sure if I get the user right. I tried: localhost, myName, root. Could that be the cause of the error? How to solve it?

    In require I put the address where I have the node modules. I am not sure if that is right?

  2. I try to learn Node.js. I have used Mamp and PHP till now. With Mamp I can access to MySql. Is that useful for Node? Probably I am confusing concepts and Mamp does not work with Node. Right? .

  3. I try to learn Node.js. I followed that tutorial: https://www.w3schools.com/nodejs/nodejs_get_started.asp

    As the tutorial says, I created a file: myfirst.js with that content: 

    var http = require('http');
    
    http.createServer(function (req, res) {
      res.writeHead(200, {'Content-Type': 'text/html'});
      res.end('Hello World!');
    }).listen(8080);

    I have a Mac. I open the Terminal and reach that file: Your Name>node myfirst.js

    I open a browser and type the address: http://localhost:8080 And I see nothing. Safari says: Safari can't connect to the Server. Similar with other browsers. 

    What is wrong?

     

    mysqli

    This means that we should not learn php in W3c? What is a good place for an absolute beginner? (I think php.net is not a good place to learn for a beginner)

    mysqli

    In the lasts months I have try to learn php. I really like w3 because explains the things in a very clear an direct way. But now I discover that I should not use mysql, that this is deprecated. More experienced people tell me that I should use mysqli I'm confused, is it true? why W3Schools does not talk about that? When will w3c update that information? Thank you Narcís

×
×
  • Create New...